Usage: {{t}}
{{t}}
is a helper to output text in your site language.
Ghost’s front-end and themes are fully translatable by enabling a publication language in the setting in Ghost admin, and using the translate helper to wrap around any plain text in your theme.
Learn more about translation in Ghost at our FAQ.
locales
folder and add language fileslocales
. If using a theme that is already translatable, this may exist already.
Inside the locales
folder, add target language files for each translatable language used on your site. For example locales/en.json
for English and locales/es.json
for Spanish. A valid language code must be used.
locales/en.json
:
locales/es.json
:
{{t}}
translation helper when no translation is available.
Dates, with month names, are automatically translated. You don’t need to include them in the translation files.
Use HTML entities instead of characters, for example <
instead of <
.
.json
translation file for your active theme is in place and then activate the language in the General settings of Ghost admin. Enter the correct language code into your settings menu and hit save.
content/themes/mytheme/partials
, copy the template
navigation.hbs - exists in content/themes/mytheme/partials
, copy the template
{{t}}
translation helper, with {{t
to the left of the text and }}
to the right.
Look for any plain text in all of your theme’s .hbs
template files and ensure the translation helper is present.
<html>
tag at the start of the theme’s default.hbs
template, using Ghost’s {{@site.locale}}
helper: <html lang="{{@site.locale}}">
. {{@site.locale}}
will automatically be replaced on the site with the corresponding language locale tag set in Ghost Admin.
ghost restart
.
default.hbs
using:
(t)
subexpression (instead of normal {{t}}
helper) can be used as a parameter inside another helper such as {{tags}}
.
This can be used to translate the prefix or suffix attribute of the {{tags}}
, {{authors}}
or {{tiers}}
helper.
{{plural}}
is a formatting helper for outputting strings which change depending on whether a number is singular or plural.
This can be used in translations to output information such as number of posts:
author.hbs
, several (t) subexpressions instead of normal {{t}}
helpers can be used as parameters inside
es.json
:
“1 min read”: “1 min de lectura”, “% min read”: “% min de lectura”, And in theme template post.hbs
And in the theme template post.hbs
:
{{meta_title}}
helper accepts a page parameter that can be used in conjunction with translations. By using the follow it’s possible to translate the word “Page” shown in the title of paginated pages: