Ghost has support for translating strings in Portal and emails. Under the hood, we use https://github.com/i18next/i18next and https://github.com/i18next/i18next-parser, so be sure to read their docs if you have questions about the tooling.

All translations are stored within the i18n package in the Ghost monorepo. The locales folder contains the languages we currently have configured, and each subfolder contains the translations in a JSON file, separated by the project they’re for. For example, portal.json contains Portal-specific strings, and test.json is just for testing purposes.

Within a JSON file, you’ll see a key-value pair of strings. The key (the left-hand side of the colon) is what we use in code. If the value (the right-hand side of the colon) is "", the string has not yet been translated and we default back to the key.

Translating strings

If you’d like to translate a string, open up a JSON file within https://github.com/TryGhost/Ghost/tree/main/ghost/i18n/locales and start writing.

Keep in mind:

Once you’re done, commit the changes and open a pull request on the Ghost repo so the team can review + merge it 🎉

Be sure to follow our contributing guide when opening a pull request, particularly the part about commit messages. Please do refs [<https://github.com/TryGhost/Team/issues/2795>](<https://github.com/TryGhost/Team/issues/2795>) on the 3rd line.

Adding a new language

<aside> 💡 We only support ISO 639-1 language codes, listed here: https://www.w3schools.com/tags/ref_language_codes.asp

</aside>

  1. Add the language code to the list of supported locales: https://github.com/TryGhost/Ghost/blob/1c9327ce33d730232a497c9fcecfae78d8c1ece2/ghost/i18n/lib/i18n.js#L3
  2. Inside ghost/i18n, run yarn translate. A new folder for your locale will be created inside ghost/i18n/locales.
  3. Commit the new changes and open a pull request on the Ghost repo so the team can review + merge it 🎉