Skip to content

Commit 516e4cb

Browse files
committed
minor #17088 [Intl] Document the emoji transliterator (javiereguiluz)
This PR was squashed before being merged into the 6.2 branch. Discussion ---------- [Intl] Document the emoji transliterator Fixes #17069. Commits ------- a6e9bc7 [Intl] Document the emoji transliterator
2 parents 9b24f8f + a6e9bc7 commit 516e4cb

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

components/intl.rst

Lines changed: 31 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,35 @@ 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+
.. versionadded:: 6.2
369+
370+
The Empoji transliteration feature was introduced in Symfony 6.2.
371+
372+
The ``EmojiTransliterator`` class provides an utility to translate emojis into
373+
their textual representation in all languages based on the `Unicode CLDR dataset`_::
374+
375+
use Symfony\Component\Intl\Transliterator\EmojiTransliterator;
376+
377+
// describe emojis in English
378+
$transliterator = EmojiTransliterator::create('en');
379+
$transliterator->transliterate('Menus with 🍕 or 🍝');
380+
// => 'Menus with pizza or spaghetti'
381+
382+
// describe emojis in Ukrainian
383+
$transliterator = EmojiTransliterator::create('uk');
384+
$transliterator->transliterate('Menus with 🍕 or 🍝');
385+
// => 'Menus with піца or спагеті'
386+
387+
.. tip::
388+
389+
Combine this emoji transliterator with the :ref:`Symfony String slugger <string-slugger>`
390+
to improve the slugs of contents that include emojis (e.g. for URLs).
391+
362392
Learn more
363393
----------
364394

@@ -381,3 +411,4 @@ Learn more
381411
.. _`daylight saving time (DST)`: https://en.wikipedia.org/wiki/Daylight_saving_time
382412
.. _`ISO 639-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_639-1
383413
.. _`ISO 639-2 alpha-3 (2T)`: https://en.wikipedia.org/wiki/ISO_639-2
414+
.. _`Unicode CLDR dataset`: https://github.com/unicode-org/cldr

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 improve 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)