Skip to content

Celebrating our new site: 30% off everything with code , until Dec 1.

Bright Themes

How to translate your theme in Ghost

Show your Ghost theme's buttons, labels and dates in your readers' language, with the theme's language files and one setting.

Norbert4 min read

You write your posts in your own language, but the theme around them has words of its own: “Subscribe”, “Read more”, “Older posts”, “5 min read”. If your site isn’t in English, those words should match your posts. Ghost lets a theme carry its text in language files, one per language, and picks the right one from a single setting.

What this covers, and what it doesn’t:

  • The theme’s own text comes from its language files. That’s what this tutorial is about.
  • Ghost’s own screens follow the same setting without any work: the sign-up and account popup (Portal), search, comments and the emails Ghost sends to members. Ghost Admin itself stays in English.
  • Dates are translated automatically: month and day names follow your language (see how the date helper works).
  • Your content isn’t translated. For a site in two languages at once, Ghost recommends one Ghost site per language when the content differs, or a translation service such as Weglot when it’s the same.

What you need

  • A login to Ghost Admin as the Owner or an Administrator.
  • A translation-ready theme. Your theme’s docs say whether it is.
  • To add or edit a language: the theme’s zip, a text editor, and a way to zip a folder again.

1. Check which languages your theme has

Unzip a copy of your theme and look for a locales folder. It holds one JSON file per language, named with the language code:

Text
locales/
├── de.json
├── en.json
├── es.json
└── fr.json

en.json is the base: every other file translates the same sentences. If your language is in the list, you only need step 2. If it isn’t, or you want to change some wording, carry on to step 3.

If the theme has no locales folder at all, it isn’t translation-ready: see “Make your own theme translatable” at the end.

2. Set your publication language

  1. Open Settings › General settings › Publication language and choose Edit.
  2. In Site language, choose your language. If it isn’t listed, choose Other… and enter its code, such as pt-BR.
  3. Choose Save.

The code must match the name of the theme’s language file: de uses de.json. Open your site: the theme’s text is now in that language. Ghost also uses the code in the page’s lang attribute, which helps screen readers and search engines, in themes that output it.

3. Add or change a language file

  1. In your unzipped theme, copy locales/en.json and name the copy after your language code, such as locales/pl.json for Polish.
  2. Open it in a text editor. Each line is a pair: the English sentence on the left, the translation on the right. Change only the right side:
locales/pl.json
{
  "Subscribe": "Subskrybuj",
  "Read more": "Czytaj dalej",
  "Older Posts": "Starsze wpisy",
  "Page {page} of {pages}": "Strona {page} z {pages}",
  "1 min read": "1 min czytania",
  "% min read": "% min czytania"
}
  1. Keep the placeholders as they are: words in braces, such as {page} or {blogtitle}, and the % sign are filled in by Ghost.
  2. Use HTML entities, such as &lt; for <, where a sentence contains HTML characters.
  3. Save the file as UTF-8, and check it’s still valid JSON: a missing comma or quote breaks the whole file. Any JSON validator in your editor or online will tell you.

To change a few words in a language the theme already has, edit that file the same way.

You don’t need to translate every line at once. A sentence missing from your file shows in English, so the site never shows a blank.

4. Upload the theme

  1. Zip the theme folder. Keep the zip’s name and the name in package.json unchanged.
  2. Upload the zip in Settings › Site › Theme › Change theme › Upload theme.
  3. When Ghost asks whether to overwrite the theme, choose Overwrite. Ghost keeps your design settings because the name is the same.

If you edit the files on your own server instead, restart Ghost with ghost restart so it reads the new file. The full upload steps are in how to install a theme in Ghost.

You can also skip the zip and work in Ghost Admin: open Settings › Site › Theme, open the menu next to your active theme and choose Edit code. Create or edit the file in locales, choose Save, then Replace theme.

5. Check the site, and keep your file safe

Look at the pages with the most theme text: the homepage, a post, a tag page, the pagination at the bottom of a list, and the sign-up forms. Anything still in English is either missing from your file, or hard-coded in a template.

Then keep a copy of your language file. A theme update replaces the locales folder with the author’s version: copy your file back in before you upload the update, as in how to update your Ghost theme to a new version. Better still, send it to the theme’s author, so the next version includes it.

Most of our themes ship with English and at least five other languages, and each theme’s docs list them under Translations.

Make your own theme translatable

If you build or edit a theme, these are the parts Ghost’s documentation asks for:

  • Wrap every piece of text in the templates in the translate helper: {{t "Subscribe"}}. Use readable English as the key, so the English text is the fallback.
  • Pass dynamic values as placeholders: {{t "Subscribe to {blogtitle}" blogtitle=@site.title}}.
  • Use (t) as a subexpression inside other helpers, for example for reading time: {{reading_time minute=(t "1 min read") minutes=(t "% min read")}}.
  • Add partials/pagination.hbs and partials/navigation.hbs, copied from Ghost’s defaults, so their text can be translated too.
  • Set the page language in default.hbs: <html lang="{{@site.locale}}">.
  • Add locales/en.json with every sentence, and one file per language you support.

Ghost’s translate helper documentation (opens in a new tab) has the full reference, including plurals.

The result

Your theme speaks your readers’ language: buttons, labels, pagination and dates all match your posts, Ghost’s own popups and emails follow the same setting, and your translation survives the next theme update.

Related posts

More on themes

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.

Get the Bright Themes newsletter

New tutorials and explainers, what changed in Ghost, and our theme releases. No spam, unsubscribe anytime.