Localizing Discourse

Discourse was always intended to be a discussion platform supporting every human language. We launched one month ago supporting only English, but since we used the default Ruby on Rails i18n gem, Discourse can be (relatively) easily translated into the language of your choice.

discourse-in-french

As of last week, you can now change the default_locale setting in the /admin settings to determine the default language of your Discourse install.

If you browse the Discourse codebase in the /config/locales folder, you'll see YAML files for each currently supported language, in client and server flavors. Every language is identified by its standard ISO 639-1 two character code.

  • client.cs.yml
  • server.cs.yml
  • client.fr.yml
  • server.fr.yml

Within each file, there are tokens on the left and translations on the right:

fr:
  js:
    share:
      topic: 'partager un lien vers cette discussion'
      post: 'partager un lien vers ce message'

    edit: 'éditer le titre et la catégorie de cette discussion'
    not_implemented: "Cette fonctionnalité n'a pas encore été implémentée, désolé."
    no_value: "Non"
    yes_value: "Oui"
cs:
  js:
    share:
      topic: 'sdílet odkaz na toto téma'
      post: 'sdílet odkaz na tento příspěvek'

    edit: 'upravit název a kategorii příspěvku'
    not_implemented: "Tato fičura ještě není implementovaná"
    no_value: "Ne"
    yes_value: "Ano"

We tried to be meticulous about calling the i18n functions when displaying strings, but we didn't always succeed.

With the help of a number of contributors, especially kubabrecka and ZogStriP, we've been cleaning up the Discourse codebase since launch and ensuring that all string output goes through the proper i18n functions. It's not difficult – wherever you see a hard-coded string, you change it into a function that references a token instead:

 <div class='alert alert-error'>
-    Something went wrong processing your log in, please try again.
+    <% t 'login.omniauth_error_unknown' %>
 </div>

Of course, Internationalization and Localization are complex topics, and we haven't even touched on date and time formats, number formats, differences in pluralization, right-to-left languages, or dozens of other subtleties.. but ensuring that we've at least sent all our strings through i18n is a big step in the right direction.

We'd love your help localizing Discourse!

If you have time to contribute, just start a YML file with the appropriate language code and structure in /config/locales, and translate from the master server.en.yml and client.en.yml files as you can. That's the main bit, but there's a bit more work required to get client-side translations and date formatting in place as well.

The more people that can use Discourse, in any language, the more conversations we can have, and the more inviting Discourse becomes to contributions from all over the world!

melted-crayon-rainbow