17. Add-on Internationalization – Effective Volto – Add-ons

Add-on Internationalization

17. Add-on Internationalization#

The internationalization workflow is the same as in main Volto: you develop your add-on, then add the translations to your code. See Creating i18n Strings for how to mark strings and phrases as translatable.

Your add-on has a locales folder with a .pot file.

  1. Create the following structure in your add-ons locales folder for every language you want to support. As an example for the language Italian:

    it
    └── LC_MESSAGES
        └── volto.po
    
  2. Make sure you depend your add-on on @plone/scripts library.

    "dependencies": {
        "@plone/scripts": "*",
    }
    

    This will allow you to run yarn i18n from inside your add-on, even if it's outside a project.

  3. Run yarn i18n in the context of your add-on.

  4. Go to each .po file in your locales folder, and write the translations for each translation literal.

In the context of your project (eg. in the root), run yarn i18n to merge the add-on translations with the ones of your project.

17.1. Override translations#

The addon loading chain is followed here as well, so the addons can override translation messages and the last addon "wins". The project translations are loaded last, so it can override any addon translations.