Skip to content

Commit 8be7bb3

Browse files
committed
[String] Update the emoji transliteration docs
1 parent 38b29fa commit 8be7bb3

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

string.rst

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,20 @@ textual representation in all languages based on the `Unicode CLDR dataset`_::
558558
$transliterator->transliterate('Menus with 🍕 or 🍝');
559559
// => 'Menus with піца or спагеті'
560560

561+
Transliterating Emoji Text Short Codes
562+
......................................
561563

562-
The ``EmojiTransliterator`` also provides special locales that convert emojis to
563-
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``.
564+
Services like GitHub and Slack allows to include emojis in your messages using
565+
text short codes (e.g. you can add the ``:+1:`` code to render the 👍 emoji).
565566

566-
GitHub Emoji Transliteration
567-
............................
567+
Symfony also provides a feature to transliterate emojis into short codes and vice
568+
versa. The short codes are slightly different on each service, so you must pass
569+
the name of the service as an argument when creating the transliterator:
568570

569-
Convert GitHub emojis to short codes with the ``emoji-github`` locale::
571+
GitHub Emoji Short Codes Transliteration
572+
########################################
573+
574+
Convert emojis to GitHub short codes with the ``emoji-github`` locale::
570575

571576
$transliterator = EmojiTransliterator::create('emoji-github');
572577
$transliterator->transliterate('Teenage 🐢 really love 🍕');
@@ -578,10 +583,10 @@ Convert GitHub short codes to emojis with the ``github-emoji`` locale::
578583
$transliterator->transliterate('Teenage :turtle: really love :pizza:');
579584
// => 'Teenage 🐢 really love 🍕'
580585

581-
Gitlab Emoji Transliteration
582-
............................
586+
Gitlab Emoji Short Codes Transliteration
587+
########################################
583588

584-
Convert Gitlab emojis to short codes with the ``emoji-gitlab`` locale::
589+
Convert emojis to Gitlab short codes with the ``emoji-gitlab`` locale::
585590

586591
$transliterator = EmojiTransliterator::create('emoji-gitlab');
587592
$transliterator->transliterate('Breakfast with 🥝 or 🥛');
@@ -593,10 +598,10 @@ Convert Gitlab short codes to emojis with the ``gitlab-emoji`` locale::
593598
$transliterator->transliterate('Breakfast with :kiwi: or :milk:');
594599
// => 'Breakfast with 🥝 or 🥛'
595600

596-
Slack Emoji Transliteration
597-
...........................
601+
Slack Emoji Short Codes Transliteration
602+
#######################################
598603

599-
Convert Slack emojis to short codes with the ``emoji-slack`` locale::
604+
Convert emojis to Slack short codes with the ``emoji-slack`` locale::
600605

601606
$transliterator = EmojiTransliterator::create('emoji-slack');
602607
$transliterator->transliterate('Menus with 🥗 or 🧆');
@@ -608,19 +613,22 @@ Convert Slack short codes to emojis with the ``slack-emoji`` locale::
608613
$transliterator->transliterate('Menus with :green_salad: or :falafel:');
609614
// => 'Menus with 🥗 or 🧆'
610615

611-
Text Emoji Transliteration
612-
..........................
616+
Universal Emoji Short Codes Transliteration
617+
###########################################
613618

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::
619+
If you don't know which service was used to generate the short codes, you can use
620+
the ``text-emoji`` locale, which combines all codes from all services::
616621

617622
$transliterator = EmojiTransliterator::create('text-emoji');
623+
618624
// Github short codes
619625
$transliterator->transliterate('Breakfast with :kiwi-fruit: or :milk-glass:');
620626
// Gitlab short codes
621627
$transliterator->transliterate('Breakfast with :kiwi: or :milk:');
622628
// Slack short codes
623629
$transliterator->transliterate('Breakfast with :kiwifruit: or :glass-of-milk:');
630+
631+
// all the above examples produce the same result:
624632
// => 'Breakfast with 🥝 or 🥛'
625633

626634
You can convert emojis to short codes with the ``emoji-text`` locale::

0 commit comments

Comments
 (0)