Skip to content

Commit 38b29fa

Browse files
committed
minor #19919 [Emoji] Add the text locale (alamirault)
This PR was squashed before being merged into the 7.1 branch. Discussion ---------- [Emoji] Add the text locale Fix #19745 (No versionadded because, emoji component was introduced in 7.1) Commits ------- 0074962 [Emoji] Add the text locale
2 parents d91396b + 0074962 commit 38b29fa

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

string.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ textual representation in all languages based on the `Unicode CLDR dataset`_::
561561

562562
The ``EmojiTransliterator`` also provides special locales that convert emojis to
563563
short codes and vice versa in specific platforms, such as GitHub, Gitlab and Slack.
564+
All theses platform are also combined in special locale ``text``.
564565

565566
GitHub Emoji Transliteration
566567
............................
@@ -607,6 +608,27 @@ Convert Slack short codes to emojis with the ``slack-emoji`` locale::
607608
$transliterator->transliterate('Menus with :green_salad: or :falafel:');
608609
// => 'Menus with 🥗 or 🧆'
609610

611+
Text Emoji Transliteration
612+
..........................
613+
614+
If you don't know where short codes come from, you can use the ``text-emoji`` locale.
615+
This locale will convert Github, Gitlab and Slack short codes to emojis::
616+
617+
$transliterator = EmojiTransliterator::create('text-emoji');
618+
// Github short codes
619+
$transliterator->transliterate('Breakfast with :kiwi-fruit: or :milk-glass:');
620+
// Gitlab short codes
621+
$transliterator->transliterate('Breakfast with :kiwi: or :milk:');
622+
// Slack short codes
623+
$transliterator->transliterate('Breakfast with :kiwifruit: or :glass-of-milk:');
624+
// => 'Breakfast with 🥝 or 🥛'
625+
626+
You can convert emojis to short codes with the ``emoji-text`` locale::
627+
628+
$transliterator = EmojiTransliterator::create('emoji-text');
629+
$transliterator->transliterate('Breakfast with 🥝 or 🥛');
630+
// => 'Breakfast with :kiwifruit: or :milk-glass:
631+
610632
Removing Emojis
611633
~~~~~~~~~~~~~~~
612634

0 commit comments

Comments
 (0)