Skip to content

Add-on Internationalization#

Volto added add-on internationalization support since Volto 11.1.0 via an enhanced src/i18n.js script. In case you can't upgrade to this version, you can still support it in your project, by backporting it and add it into your project's workflow.

  1. Copy over the updated https://github.com/plone/volto/blob/master/src/i18n.js script to your project, e.g src/i18n.js

  2. Update your project's package.json to call it, instead of calling the inner Volto one.

  "scripts": {
...
    "i18n": "NODE_ENV=production node src/i18n.js",
...
  }

Add locales to your add-on#

An specific src/i18n.js script has been added to the addon generator in order to do this task. You can find it here:

https://github.com/plone/volto/blob/master/packages/generator-volto/generators/addon/templates/src/i18n.js

If you start over a new project and you have an up to date generator, generating a project will already contain it.

If you have already an addon and you want to add internationalization to it:

  1. Copy it over to your addon as src/i18n.js
  2. Update your project's package.json to call it, instead of calling the inner Volto one.
  "scripts": {
...
    "i18n": "NODE_ENV=production node src/i18n.js",
...
  }
  1. Create an initial locales folder and create an empty .pot file like this one: https://github.com/plone/volto/blob/master/packages/generator-volto/generators/addon/templates/locales/volto.pot

Internationalization workflow#

The internationalization workflow is the same as in main Volto, you develop your add-on, add the translations to your code.

  1. Run yarn i18n in the context of your add-on to generate the locales directory.
  2. Go to each .po file in your locales folder and write the translations for each translation literal.

In the context of your project, run yarn i18n to merge the add-on translations with the ones of your project.

Override translations#

The workflow allows to override translations from your project scope, so the project translations "always win".