Skip to content

Commit f739172

Browse files
committed
[Intl] Document the emoji transliterator
1 parent 1724e35 commit f739172

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

components/intl.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ This component provides the following ICU data:
3939
* `Locales`_
4040
* `Currencies`_
4141
* `Timezones`_
42+
* `Emoji Transliteration`_
4243

4344
Language and Script Names
4445
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -359,6 +360,31 @@ to catching the exception, you can also check if a given timezone ID is valid::
359360

360361
$isValidTimezone = Timezones::exists($timezoneId);
361362

363+
.. _component-intl-emoji-transliteration:
364+
365+
Emoji Transliteration
366+
~~~~~~~~~~~~~~~~~~~~~
367+
368+
The ``EmojiTransliterator`` class provides an utility to translate emojis into
369+
their textual represtation in all languages::
370+
371+
use Symfony\Component\Intl\Transliterator\EmojiTransliterator;
372+
373+
// describe emojis in English
374+
$transliterator = EmojiTransliterator::create('en');
375+
$transliterator->transliterate('Menus with 🍕 or 🍝');
376+
// => 'Menus with pizza or spaghetti'
377+
378+
// describe emojis in Ukrainian
379+
$transliterator = EmojiTransliterator::create('uk');
380+
$transliterator->transliterate('Menus with 🍕 or 🍝');
381+
// => 'Menus with піца or спагеті'
382+
383+
.. tip::
384+
385+
Combine this emoji transliterator with the :ref:`Symfony String slugger <string-slugger>`
386+
to impove the slugs of contents that include emojis (e.g. for URLs).
387+
362388
Learn more
363389
----------
364390

components/string.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,8 @@ letter A with ring above"*) or a sequence of two code points (``U+0061`` =
451451
u('å')->normalize(UnicodeString::NFD);
452452
u('å')->normalize(UnicodeString::NFKD);
453453

454+
.. _string-slugger:
455+
454456
Slugger
455457
-------
456458

@@ -486,6 +488,11 @@ another separator as the second argument::
486488
$slug = $slugger->slug('Wôrķšƥáçè ~~sèťtïñğš~~', '/');
487489
// $slug = 'Workspace/settings'
488490

491+
.. tip::
492+
493+
Combine this slugger with the :ref:`Symfony emoji transliterator <component-intl-emoji-transliteration>`
494+
to impove the slugs of contents that include emojis (e.g. for URLs).
495+
489496
The slugger transliterates the original string into the Latin script before
490497
applying the other transformations. The locale of the original string is
491498
detected automatically, but you can define it explicitly::

0 commit comments

Comments
 (0)