ausi/slug-generator

Cyrillic/Russian generation

Sogl opened this issue · 3 comments

Sogl commented

For example, I tried to convert name Артём to artyom.

What I tried (under the numbers are code options):

$generator = new SlugGenerator;

//1

$generator = new SlugGenerator((new SlugOptions)->setLocale('ru'));

//2
$str = $generator->generate($str, ['locale' => 'ru']);

//3
$str = $generator->generate($str, ['locale' => 'uk', 'preTransforms' => ['uk-uk_Latn/BGN']]);

Last option from this issue: #19

Wrong result artem in all cases.
How to fix?

ausi commented

Seems that the rules of the unicode library think that ё should be transformed to ё and not to yo see https://github.com/unicode-org/cldr/blob/7825c7bfc1d036b9911e467c620c7cfe224ef45e/common/transforms/Russian-Latin-BGN.xml#L122-L132

Can you point me to the rules that discrible how to transform Артём to artyom?

ausi commented

There doesn’t seem to be a matching transform available in the CLDR: https://github.com/unicode-org/cldr/tree/main/common/transforms

But you could still prepend your own rules to achieve the desired result:

$generator->generate($str, ['locale' => 'ru', 'preTransforms' => ['ё>yo;']]);

More information about the rule syntax can be found in the ICU documentation: https://unicode-org.github.io/icu/userguide/transforms/general/rules.html