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.
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:
{{something}}
- it’s a variable in the code, so we need to keep that in the translated stringOnce 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.
<aside> 💡 We only support ISO 639-1 language codes, listed here: https://www.w3schools.com/tags/ref_language_codes.asp
</aside>
ghost/i18n
, run yarn translate
. A new folder for your locale will be created inside ghost/i18n/locales
.