How can badges and groups be localized (multilingual)?

How can badges and groups be localized (multilingual)? During setup, I noticed that the titles of badges and groups do not switch with the theme language. How can I make badges and groups follow the theme switch?

3 Likes

The ability to localize custom badges and groups for a multilingual site doesn’t exist yet — at the moment only posts, categories, and tags can be localized.

Okay, thank you. But why is it that the badges on this website (meta.discourse.org) switch language along with the theme? Is that caused by a translation feature? I suggest that the official team add multilingual customization settings for badges, groups, and tags; otherwise, multilingual users cannot understand the content of badges, groups, and tags.

1 Like

There are some seeded badges on every site that are internationalised (i18n) through Crowdin.

Custom badges store name/description as plain text in the database. When I18n.t (internationalization feature) is called with a key like badges.my_custom_badge.name, there’s no matching translation, so it falls back to the stored DB value — same text for all locales.

There’s a workaround where admins can manually add translations for custom badge keys per locale.

You can customize your site texts at <your site>/admin/customize/site_texts.


Some concrete steps for you

  1. Create the badge
  • Go to /admin/badges → New Badge
  • Set name, description, icon, etc. as normal
  1. Derive the i18n key
  • The key pattern is badges.{snake_case_name}.name
  • The snake_case_name is the badge name lowercased with spaces replaced by underscores
  • So “PokĂ©mon Master” → badges.pokĂ©mon_master.name
  1. Add translation overrides
  • Go to /admin/customize/site_texts
  • Search for badges.pokĂ©mon_master
  • You’ll see keys like:
    • badges.pokĂ©mon_master.name
    • badges.pokĂ©mon_master.description
    • badges.pokĂ©mon_master.long_description
  • Switch to the target locale (e.g. 简体中文), click the key, and enter the translated text
  1. Repeat per locale
  • Switch locale in the dropdown, add translations for each language you need
    • .name - badge title
    • .description - short description shown on badge cards
    • .long_description - full description shown on the badge detail page

english

japanese

Hi! Thanks for the reply! How is the second step, finding the “i18n key,” implemented? I couldn’t find the location of the i18n key.

You don’t really “find” it, just derive it from the name you will give the badge. (Will update the second step to use “derive” instead of “find”)

So if you use “Bug Finder” as the badge name, the key will be badges.bug_finder.name