@@ -558,15 +558,20 @@ textual representation in all languages based on the `Unicode CLDR dataset`_::
558
558
$transliterator->transliterate('Menus with 🍕 or 🍝');
559
559
// => 'Menus with піца or спагеті'
560
560
561
+ Transliterating Emoji Text Short Codes
562
+ ......................................
561
563
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).
565
566
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:
568
570
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::
570
575
571
576
$transliterator = EmojiTransliterator::create('emoji-github');
572
577
$transliterator->transliterate('Teenage 🐢 really love 🍕');
@@ -578,10 +583,10 @@ Convert GitHub short codes to emojis with the ``github-emoji`` locale::
578
583
$transliterator->transliterate('Teenage :turtle: really love :pizza:');
579
584
// => 'Teenage 🐢 really love 🍕'
580
585
581
- Gitlab Emoji Transliteration
582
- ............................
586
+ Gitlab Emoji Short Codes Transliteration
587
+ ########################################
583
588
584
- Convert Gitlab emojis to short codes with the ``emoji-gitlab `` locale::
589
+ Convert emojis to Gitlab short codes with the ``emoji-gitlab `` locale::
585
590
586
591
$transliterator = EmojiTransliterator::create('emoji-gitlab');
587
592
$transliterator->transliterate('Breakfast with 🥝 or 🥛');
@@ -593,10 +598,10 @@ Convert Gitlab short codes to emojis with the ``gitlab-emoji`` locale::
593
598
$transliterator->transliterate('Breakfast with :kiwi: or :milk:');
594
599
// => 'Breakfast with 🥝 or 🥛'
595
600
596
- Slack Emoji Transliteration
597
- ...........................
601
+ Slack Emoji Short Codes Transliteration
602
+ #######################################
598
603
599
- Convert Slack emojis to short codes with the ``emoji-slack `` locale::
604
+ Convert emojis to Slack short codes with the ``emoji-slack `` locale::
600
605
601
606
$transliterator = EmojiTransliterator::create('emoji-slack');
602
607
$transliterator->transliterate('Menus with 🥗 or 🧆');
@@ -608,19 +613,22 @@ Convert Slack short codes to emojis with the ``slack-emoji`` locale::
608
613
$transliterator->transliterate('Menus with :green_salad: or :falafel:');
609
614
// => 'Menus with 🥗 or 🧆'
610
615
611
- Text Emoji Transliteration
612
- ..........................
616
+ Universal Emoji Short Codes Transliteration
617
+ ###########################################
613
618
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 ::
616
621
617
622
$transliterator = EmojiTransliterator::create('text-emoji');
623
+
618
624
// Github short codes
619
625
$transliterator->transliterate('Breakfast with :kiwi-fruit: or :milk-glass:');
620
626
// Gitlab short codes
621
627
$transliterator->transliterate('Breakfast with :kiwi: or :milk:');
622
628
// Slack short codes
623
629
$transliterator->transliterate('Breakfast with :kiwifruit: or :glass-of-milk:');
630
+
631
+ // all the above examples produce the same result:
624
632
// => 'Breakfast with 🥝 or 🥛'
625
633
626
634
You can convert emojis to short codes with the ``emoji-text `` locale::
0 commit comments