-
-
Notifications
You must be signed in to change notification settings - Fork 332
Enable translation
If you will use in English only, you can skip this.
To enable a custom translation you need to enable i18n and choose your language.
At first clone the pelican-plugins repository and enable i18n for your pelican site by adding the following code to your pelicanconf.py
:
# Path to Plugins
PLUGIN_PATHS = ['/path/to/pelican-plugins']
# Enable i18n plugin, probably you already have some others here.
PLUGINS = ['i18n_subsites']
# Enable Jinja2 i18n extension used to parse translations.
JINJA_ENVIRONMENT = {'extensions': ['jinja2.ext.i18n']}
With this done you can use the theme with texts in the English language as usual.
The step above only enable i18n, but it won't translate anything from English.
If you want to translate to another language you need to change DEFAULT_LANG
and I18N_TEMPLATES_LANG
in your pelicanconf.py
. You should change LOCALE
and OG_LOCALE
to match your new configuration too.
IMPORTANT: I18N_TEMPLATES_LANG
must not be set to the language in which you want to translate your site, but to the original language in which templates are written (in this case, en
).
For example:
# Default theme language.
I18N_TEMPLATES_LANG = "en"
# Your language.
DEFAULT_LANG = "de_DE"
# Match languages for other configs.
OG_LOCALE = "de_DE"
LOCALE = ("de_DE", "de_DE.utf8")
Now your site will be translated into your language.
Language code (
de_DE
) must be available in Translations to work.