Forum

Thread tagged as: Question

Umlauts in URL (again)

Are there any new insights regarding https://forum.grabaperch.com/forum/08-12-2015-german-umlaute-in-slugsurls ?

I am using the latest Perch Runway version 2.8.29 with PHP 7, Diagnosis says "Transliteration functions: Yes" (seems like that's built in by default now).

The locale is set in config.php:

 setlocale(LC_ALL, 'de_CH.UTF-8');

Which matches what I get for "locale" on the command line (LC_CTYPE="de_CH.UTF-8")

But a Slug field

<perch:content id="projectSlug" label="Artikel-URL" type="slug" for="projectTitle" />

will still output "kase" instead of "kaese" if projectTitle is set to "Käse".

I'm not asking you to debug this, but maybe you know of another place I could check?

Urs Bräm

Urs Bräm 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Here's what we're doing:

$tranliterator_rule = 'Any-Latin; Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();';
$T = Transliterator::create($tranliterator_rule);
$s = $T->transliterate($string);

Where $string is the input and $s is the output.

Thanks! Seems like this doesn't transliterate "a" to "ae" and so on; also https://php.net/manual/en/transliterator.transliterate.php doesn't mention such transliteration.

Probably the help of mbstring or iconv would be needed here?

On the contrary, when the slug field is visible in the admin tool, the transliteration happens via javascript from the title, and the "ae" is being created as expected.

PS there's a (consistent) typo here: $tranliterator

Drew McLellan

Drew McLellan 2638 points
Perch Support

Probably the help of mbstring or iconv would be needed here?

The transliterator is supposed to supersede iconv, and iconv is a nightmare for us to support across systems.

there's a (consistent) typo here: $tranliterator

I'm not going to lose sleep ;)