-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sluggable and accents #173
Comments
There is a problem with iconv. |
Saw this on https://php.net/manual/fr/function.iconv.php
https://github.com/KnpLabs/DoctrineBehaviors/blob/master/src/Model/Sluggable/SluggableMethods.php Is that the right thing to do ? |
Unfortunatly, I never had to run into those problems, and I have no idea how transliteration works :) |
accents like áéóèàñß not been converted i think is possible to modify generateSlug function with this public function generateSlug()
{
if ( $this->getRegenerateSlugOnUpdate() || empty( $this->slug ) ) {
$fields = $this->getSluggableFields();
$usableValues = [];
foreach ($fields as $field) {
// Too bad empty is a language construct...otherwise we could use the return value in a write context :)
$val = $this->{$field};
if ( !empty( $val ) ) {
$usableValues[] = $val;
}
}
if ( count($usableValues) < 1 ) {
throw new \UnexpectedValueException('Sluggable expects to have at least one usable (non-empty) field from the following: [ ' . implode($fields, ',') .' ]');
}
// generate the slug itself
$sluggableText = implode($usableValues, ' ');
$sluggableText = strtr(utf8_decode($sluggableText), utf8_decode('ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'),
'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy');
$urlized = strtolower( trim( preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', iconv('UTF-8', 'ASCII//TRANSLIT', $sluggableText) ), $this->getSlugDelimiter() ) );
$urlized = preg_replace("/[\/_|+ -]+/", $this->getSlugDelimiter(), $urlized);
$this->slug = $urlized;
}
} What do you think about insert this conversion? $sluggableText = strtr(utf8_decode($sluggableText), utf8_decode('ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'),
'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy'); Words like 'Café', 'Niño', 'ße' become 'cafe', 'nino', 'be' |
@markitosgv It does not supports polish characters ążśźęćńół ĄŻŚŹĘĆŃÓŁ |
And look at #162 it solve that problem. |
@CharlyPoppins I've added your examples as test cases in #162 |
Thanks, not used to git yet. So that means I need to wait an "admin" to merge your pull request #162 and then I can do a composer update of that git : "knplabs/doctrine-behaviors": "dev-master". |
@CharlyPoppins exactly |
Ok perfect :) Thanks again |
Hello,
sluggable is not handling accents. Is that normal or did I miss something in the settings ?
The text was updated successfully, but these errors were encountered: