-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[Intl] Add EmojiTransliterator
to translate emoji to many locales
#46755
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
Conversation
src/Symfony/Component/Intl/Resources/bin/transliterator-emoji-rules.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Intl/Transliterator/EmojiTransliterator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Intl/Resources/bin/transliterator-emoji-rules.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Intl/Transliterator/EmojiTransliterator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Intl/Transliterator/EmojiTransliterator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Intl/Tests/Transliterator/EmojiTransliteratorTest.php
Outdated
Show resolved
Hide resolved
Did you want to also provide a map for short names that could work both ways? |
c6c5bb2
to
7cd2a11
Compare
@alamirault you review the PR a bit too soon :) It was a WIP (I pushed in order to backup my work).
That's already the case, or I missed something ? public function testTransliterate()
{
$tr = EmojiTransliterator::getInstance('en');
$this->assertSame(
'a grinning cat, black cat, and a lion go to national park️... smiling face with heart-eyes party popper yellow heart',
$tr->transliterate('a 😺, 🐈⬛, and a 🦁 go to 🏞️... 😍 🎉 💛')
);
} |
src/Symfony/Component/Intl/Transliterator/EmojiTransliterator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Intl/Transliterator/EmojiTransliterator.php
Outdated
Show resolved
Hide resolved
@stof Thanks for the review, I've addressed your comments. I think the PR is now ready. |
ddc8dd7
to
066e257
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice :)
I just have minor comments.
In a follow up, it'd be great to add two more locales:
en_github
sourced from https://api.github.com/emojisen_slack
sourced from https://github.com/iamcal/emoji-data
src/Symfony/Component/Intl/Transliterator/EmojiTransliterator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Intl/Transliterator/EmojiTransliterator.php
Outdated
Show resolved
Hide resolved
I missed that point! What do you recommend? we can merge en into en_ca? |
that might increase the size of maps, better run the str_replace twice when needed (with the php-based implem) |
I went this way actually, not much to merge. The PR on your fork is up to date. |
@nicolas-grekas Feel free to merge this PR, and then you can open a new PR to improve the situation if it needs to |
@lyrixx Let's finish this PR before merging it. I don't see why we would merge something that we know is not finished yet. |
Today, I used the AsciiSlugger and I was really surprised that it replaced
my emoji with nothing (a blank string). I dig a bit, and I think the best way
to solve that is to add a EmojiTransliterator, and then wire it (another PR)
Current API:
To do that, I built some transliterator rules, and I committed them to the repository.
The sources come from the official data at https://github.com/unicode-org/cldr