@@ -451,8 +451,6 @@ 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-
456454Slugger
457455-------
458456
@@ -488,11 +486,6 @@ another separator as the second argument::
488486 $slug = $slugger->slug('WΓ΄rΔ·Ε‘Ζ₯Ñçè ~~sΓ¨Ε₯tΓ―Γ±ΔΕ‘~~', '/');
489487 // $slug = 'Workspace/settings'
490488
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-
496489The slugger transliterates the original string into the Latin script before
497490applying the other transformations. The locale of the original string is
498491detected automatically, but you can define it explicitly::
@@ -526,6 +519,36 @@ the injected slugger is the same as the request locale::
526519 }
527520 }
528521
522+ .. _string-slugger-emoji :
523+
524+ Slug emojis
525+ ~~~~~~~~~~~
526+
527+ You can can transform any emojis into a textual representation::
528+
529+ use Symfony\Component\String\Slugger\AsciiSlugger;
530+
531+ $slugger = new AsciiSlugger();
532+ $slugger = $slugger->withEmoji();
533+
534+ $slug = $slugger->slug('a πΊ, πββ¬, and a π¦ go to ποΈ', '-', 'en');
535+ // $slug = 'a-grinning-cat-black-cat-and-a-lion-go-to-national-park';
536+
537+ $slug = $slugger->slug('un πΊ, πββ¬, et un π¦ vont au ποΈ', '-', 'fr');
538+ // $slug = 'un-chat-qui-sourit-chat-noir-et-un-tete-de-lion-vont-au-parc-national';
539+
540+ If you want to use a specific locale for the emoji, or to use the shorts code
541+ from `github ` or `slack `, use the first argument of ``withEmoji() `` method:
542+
543+ use Symfony\C omponent\S tring\S lugger\A sciiSlugger;
544+
545+ $slugger = new AsciiSlugger();
546+ $slugger = $slugger->withEmoji('github'); // or "en", or "fr", etc.
547+
548+ $slug = $slugger->slug('a πΊ, πββ¬, and a π¦');
549+ // $slug = 'a-smiley-cat-black-cat-and-a-lion';
550+
551+
529552.. _string-inflector :
530553
531554Inflector
0 commit comments