@@ -32,7 +32,7 @@ to compress the internal Symfony emoji data files using the PHP ``zlib`` extensi
32
32
.. _emoji-transliteration :
33
33
34
34
Emoji Transliteration
35
- ~~~~~~~~~~~~~~~~~~~~~
35
+ ---------------------
36
36
37
37
The ``EmojiTransliterator `` class offers a way to translate emojis into their
38
38
textual representation in all languages based on the `Unicode CLDR dataset `_::
@@ -49,11 +49,13 @@ textual representation in all languages based on the `Unicode CLDR dataset`_::
49
49
$transliterator->transliterate('Menus with 🍕 or 🍝');
50
50
// => 'Menus with піца or спагеті'
51
51
52
- You can also combine the ``EmojiTransliterator `` with the :ref: `slugger <string-slugger-emoji >`
53
- to transform any emojis into their textual representation.
52
+ .. tip ::
53
+
54
+ When using the :ref: `slugger <string-slugger >` from the String component,
55
+ you can combine it with the ``EmojiTransliterator `` to :ref: `slugify emojis <string-slugger-emoji >`.
54
56
55
57
Transliterating Emoji Text Short Codes
56
- ......................................
58
+ --------------------------------------
57
59
58
60
Services like GitHub and Slack allows to include emojis in your messages using
59
61
text short codes (e.g. you can add the ``:+1: `` code to render the 👍 emoji).
@@ -62,6 +64,9 @@ Symfony also provides a feature to transliterate emojis into short codes and vic
62
64
versa. The short codes are slightly different on each service, so you must pass
63
65
the name of the service as an argument when creating the transliterator.
64
66
67
+ GitHub Emoji Short Codes Transliteration
68
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
69
+
65
70
Convert emojis to GitHub short codes with the ``emoji-github `` locale::
66
71
67
72
$transliterator = EmojiTransliterator::create('emoji-github');
@@ -74,15 +79,40 @@ Convert GitHub short codes to emojis with the ``github-emoji`` locale::
74
79
$transliterator->transliterate('Teenage :turtle: really love :pizza:');
75
80
// => 'Teenage 🐢 really love 🍕'
76
81
77
- .. note ::
82
+ Gitlab Emoji Short Codes Transliteration
83
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
84
+
85
+ Convert emojis to Gitlab short codes with the ``emoji-gitlab `` locale::
86
+
87
+ $transliterator = EmojiTransliterator::create('emoji-gitlab');
88
+ $transliterator->transliterate('Breakfast with 🥝 or 🥛');
89
+ // => 'Breakfast with :kiwi: or :milk:'
90
+
91
+ Convert Gitlab short codes to emojis with the ``gitlab-emoji `` locale::
92
+
93
+ $transliterator = EmojiTransliterator::create('gitlab-emoji');
94
+ $transliterator->transliterate('Breakfast with :kiwi: or :milk:');
95
+ // => 'Breakfast with 🥝 or 🥛'
96
+
97
+ Slack Emoji Short Codes Transliteration
98
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
99
+
100
+ Convert emojis to Slack short codes with the ``emoji-slack `` locale::
101
+
102
+ $transliterator = EmojiTransliterator::create('emoji-slack');
103
+ $transliterator->transliterate('Menus with 🥗 or 🧆');
104
+ // => 'Menus with :green_salad: or :falafel:'
105
+
106
+ Convert Slack short codes to emojis with the ``slack-emoji `` locale::
78
107
79
- Github, Gitlab and Slack are currently available services in
80
- ``EmojiTransliterator ``.
108
+ $transliterator = EmojiTransliterator::create('slack-emoji');
109
+ $transliterator->transliterate('Menus with :green_salad: or :falafel:');
110
+ // => 'Menus with 🥗 or 🧆'
81
111
82
112
.. _text-emoji :
83
113
84
114
Universal Emoji Short Codes Transliteration
85
- ###########################################
115
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
86
116
87
117
If you don't know which service was used to generate the short codes, you can use
88
118
the ``text-emoji `` locale, which combines all codes from all services::
@@ -106,7 +136,7 @@ You can convert emojis to short codes with the ``emoji-text`` locale::
106
136
// => 'Breakfast with :kiwifruit: or :milk-glass:
107
137
108
138
Inverse Emoji Transliteration
109
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
139
+ -----------------------------
110
140
111
141
Given the textual representation of an emoji, you can reverse it back to get the
112
142
actual emoji thanks to the :ref: `emojify filter <reference-twig-filter-emojify >`:
@@ -129,7 +159,7 @@ specific catalog to use:
129
159
{{ ':kiwi: is a great fruit'|emojify('gitlab') }} {# renders: 🥝 is a great fruit #}
130
160
131
161
Removing Emojis
132
- ~~~~~~~~~~~~~~~
162
+ ---------------
133
163
134
164
The ``EmojiTransliterator `` can also be used to remove all emojis from a string,
135
165
via the special ``strip `` locale::
0 commit comments