Case-changing Twig filters and slug generation aren't language-aware (Turkish İ becomes "i" + U+0307) #19555
|
A little unsure whether to label this as a bug or feature request, so kept it to Discussions for now... DescriptionTwig's The most visible symptom: lowercasing the dotted capital İ (U+0130) yields a plain Twig itself has no notion of a current language, so this is reasonable behaviour for Twig core. Craft does know the language ( Steps to reproduce
Expected
Actual
Proposed solutionMake the casing filters and $lang = strtolower(explode('-', Craft::$app->language)[0]);
$transliterator = Transliterator::create("$lang-Title"); // also "-Lower", "-Upper"
if ($transliterator) {
$string = Normalizer::normalize($string, Normalizer::FORM_C);
return $transliterator->transliterate($string);
}
return CoreExtension::titleCase($charset, $string);ICU returns Slug generation could use the same lowercasing path, or NFC-normalise before filtering, so the combining mark can't survive into a URI. WorkaroundRegister a Twig extension that overrides the four filters with the above, via Additional info
|
Replies: 1 comment 1 reply
|
Thanks for pointing that out! I’ve made those casing filters and PHP-based slug generation language-aware for Craft 5.12, as well as the next Craft 6 alpha release (#19558). |
Thanks for pointing that out! I’ve made those casing filters and PHP-based slug generation language-aware for Craft 5.12, as well as the next Craft 6 alpha release (#19558).