Add English and translated aliases for Emojis

AI-generated summary

The discussion focuses on enhancing the Discourse emoji picker by adding support for English and translated search aliases, leveraging data from the Unicode Consortium. gerhard proposed a two-part solution: implementing proper English aliases and enabling per-locale aliases (e.g., typing :sourire in French to find the smile emoji). While j.jaffeux emphasized the need for lazy loading to manage performance, sam suggested using locale-specific files like alias.en and alias.de. codinghorror inquired about the status, to which gerhard confirmed the work was scheduled for the next release.

A side discussion emerged regarding custom emoji groups. SvenC56 asked how to override translation keys for custom groups. j.jaffeux provided a workaround using I18n.translations, though SvenC56 reported issues with the emoji_picker namespace not being available. gerhard suggested a fallback strategy using default values or a more complex runtime translation override system.

The feature was prioritized following a related report 16. vinothkannans contributed a PR to the emoji-db repository to include search aliases. Ultimately, Falco announced the implementation via pull requests in discourse-emojis and discourse. This update not only introduced comprehensive localized search aliases but also resolved a bug that reduced the emojis.json payload by 160KB. Falco confirmed that users can now search using translated terms (e.g., :sourire for French) and expanded support to additional languages in subsequent updates 28.

Continuing the discussion from Add alias support to emoji picker:

Our Emoji picker could be greatly improved by adding support for English and translated search aliases. The Unicode Consortium provides all the data we need:

This feature consists of two parts:

  1. Doing all the aliases properly for English
  2. Adding support for per locale aliases, so you can type :sourire in French on French sites and get :smile: in the window.

I’m putting it on my list.

16 Likes

Just as a note here, we need it to be lazy loaded, this is why I haven’t been doing it yet.

7 Likes

I think it is fine to have alias.en and alias.de etc… files, so we can lazy load per locale.

4 Likes

Isn’t this complete @gerhard?

No, not yet. I decided to work on it next month because it was moved to the next release.

5 Likes

Just found out about this “public” list of translated emoji aliases: Translations

3 Likes

Hey

I have a general question. I created my custom emoji group. How do I override this translation key? :slight_smile:

Thank you.

Currently you have to add translations into a theme or component, in your case it would be something like:

<script>
    I18n.translations.en.js.emoji_picker.twitch = "Twitch";
</script>

You can also add de if you need a different name for de.

@gerhard I had to ask you about this, do you see a better way to accomplish this given custom group names are set by admins ?

7 Likes

The easiest solution I can think of is to use the custom group name if the translation can’t be found. The only problem I’m seeing is that group names seem to be converted to lowercase.

I18n.t("emoji_picker.twitch", { defaultValue: "twitch" })

The more involved solution would be to make SiteTextsController and TranslationOverride work with custom emoji group names (or any other custom translation that needs to be added at runtime).

2 Likes

Cool might investigate the second one at some point, thanks.

2 Likes

Hey I just did console.log(I18n.translations.en.js) which outputs me the following:

It seems that emoji_picker is not available for a translation for me. There are also no effects if I paste in your code into my theme head.

Thank you.

1 Like

This was reported again here: (now closed)

We will be prioritizing this and get to it in the next release.

4 Likes

https://github.com/jjaffeux/emoji-db/pull/7

@j.jaffeux I created a PR to include search aliases in our emoji-db repo.

5 Likes

This has been implemented in the following pull requests:

https://github.com/discourse/discourse-emojis/pull/12

https://github.com/discourse/discourse/pull/39089

In the process, a bug was resolved that reduced the emojis.json payload by 160KB :smiling_face_with_sunglasses:

This introduces comprehensive localized search aliases.

4 Likes

I merged support for localized emoji aliases for some languages, so we finally

as well as

4 Likes

This topic was automatically closed after 13 days. New replies are no longer allowed.

Expanding this further

https://github.com/discourse/discourse-emojis/pull/13

3 Likes