diff --git a/components/intl.rst b/components/intl.rst index 8e5ce01be50..df3d579540e 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -39,6 +39,7 @@ This component provides the following ICU data: * `Locales`_ * `Currencies`_ * `Timezones`_ +* `Emoji Transliteration`_ Language and Script Names ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -359,6 +360,35 @@ to catching the exception, you can also check if a given timezone ID is valid:: $isValidTimezone = Timezones::exists($timezoneId); +.. _component-intl-emoji-transliteration: + +Emoji Transliteration +~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 6.2 + + The Empoji transliteration feature was introduced in Symfony 6.2. + +The ``EmojiTransliterator`` class provides an utility to translate emojis into +their textual representation in all languages based on the `Unicode CLDR dataset`_:: + + use Symfony\Component\Intl\Transliterator\EmojiTransliterator; + + // describe emojis in English + $transliterator = EmojiTransliterator::create('en'); + $transliterator->transliterate('Menus with 🍕 or 🍝'); + // => 'Menus with pizza or spaghetti' + + // describe emojis in Ukrainian + $transliterator = EmojiTransliterator::create('uk'); + $transliterator->transliterate('Menus with 🍕 or 🍝'); + // => 'Menus with піца or спагеті' + +.. tip:: + + Combine this emoji transliterator with the :ref:`Symfony String slugger ` + to improve the slugs of contents that include emojis (e.g. for URLs). + Learn more ---------- @@ -381,3 +411,4 @@ Learn more .. _`daylight saving time (DST)`: https://en.wikipedia.org/wiki/Daylight_saving_time .. _`ISO 639-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_639-1 .. _`ISO 639-2 alpha-3 (2T)`: https://en.wikipedia.org/wiki/ISO_639-2 +.. _`Unicode CLDR dataset`: https://github.com/unicode-org/cldr diff --git a/components/string.rst b/components/string.rst index c71d68a704e..455ef90eafe 100644 --- a/components/string.rst +++ b/components/string.rst @@ -451,6 +451,8 @@ letter A with ring above"*) or a sequence of two code points (``U+0061`` = u('å')->normalize(UnicodeString::NFD); u('å')->normalize(UnicodeString::NFKD); +.. _string-slugger: + Slugger ------- @@ -486,6 +488,11 @@ another separator as the second argument:: $slug = $slugger->slug('Wôrķšƥáçè ~~sèťtïñğš~~', '/'); // $slug = 'Workspace/settings' +.. tip:: + + Combine this slugger with the :ref:`Symfony emoji transliterator ` + to improve the slugs of contents that include emojis (e.g. for URLs). + The slugger transliterates the original string into the Latin script before applying the other transformations. The locale of the original string is detected automatically, but you can define it explicitly::