Skip to content
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

Cyrillic/Russian generation #30

Open
Sogl opened this issue Sep 23, 2022 · 3 comments
Open

Cyrillic/Russian generation #30

Sogl opened this issue Sep 23, 2022 · 3 comments

Comments

@Sogl
Copy link

Sogl commented Sep 23, 2022

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
Copy link
Owner

ausi commented Sep 24, 2022

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?

@Sogl
Copy link
Author

Sogl commented Sep 24, 2022

https://en.wikipedia.org/wiki/Romanization_of_Russian#Transliteration_table

ISO 9:1995; GOST 7.79-2000(A) is the closest

@ausi
Copy link
Owner

ausi commented Oct 1, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants