New in Symfony 7.1: Emoji Improvements

New Emoji Component

Contributed by
Simon Andrรฉ

in #53096.

In Symfony 6.2 we introduced a feature to transliterate and slugify emojis.
This works by adding to the Symfony Intl component all the emoji data from the
ICU library. This data includes the descriptions of all emojis and all its
variants in all languages.

As a result, when you create a fresh new Symfony application, symfony/intl
takes more than 70% of the total installation size (43MB unzipped). This is going
to get worse as more emojis are added in the future.

That’s why in Symfony 7.1 we’ve decided to remove the emoji data from Symfony Intl
and move it to a new Emoji component. The only difference in practice is that
when transliterating/slugifying emojis, you need to run this first in your project
to install the new component:

$ compose require symfony/emoji

Emojify Twig Filter

Contributed by
Grรฉgoire Pineau

in #54432.

For those applications that handle emojis, Symfony 7.1 adds a new emojify filter
that transforms the textual representation of an emoji (e.g. :wave:) into the
actual emoji (๐Ÿ‘‹):

{{ ‚This is :+1: from me’|emojify }} {# renders: This is ๐Ÿ‘ from me #}
{{ ‚This is :+1: from me’|emojify(‚github‘) }} {# renders: This is ๐Ÿ‘ from me #}
{{ ‚This is :thumbsup: from me’|emojify(‚gitlab‘) }} {# renders: This is ๐Ÿ‘ from me #}

The optional argument of the filter defines the emoji catalog that was used to
transliterate the emojis. The gitlab catalog was also introduced in Symfony 7.1
by Antoine Lamirault`_ in `PR #54441.

A Common Emoji Text Code Catalog

Contributed by
Nicolas Grekas

in #54470.

Emojis are the same everywhere, but the text codes used to represent them vary
from one service to another. For example, ๐Ÿฅ is :kiwi-fruit: in GitHub,
:kiwi: in GitLab, and :kiwifruit: in Slack.

That’s why in Symfony 7.1 we’re adding a common emoji text code catalog
that merges the text codes of all the other catalogs into a single one called text:

{{ ‚I like :kiwi-fruit:’|emojify(‚text‘) }} {# renders: I like ๐Ÿฅ #}
{{ ‚I like :kiwi:’|emojify(‚text‘) }} {# renders: I like ๐Ÿฅ #}
{{ ‚I like :kiwifruit:’|emojify(‚text‘) }} {# renders: I like ๐Ÿฅ #}

Sponsor the Symfony project.

Symfony Blog

Read More

Latest News

PHP-Releases

PHP 8.4.1 released!

PHP 8.1.31 released!

PHP 8.3.14 released!

PHP 8.2.26 released!

Generated by Feedzy