Other than the default Panini pieces, you will also need to make sure that lodash
is included as a devDependencies in your package.json
Tag a section of text as translatable. The section will be replaced with a set of if/elseif/else Merge Tags for each translation provided, otherwise only the wrapped content is displayed.
Translations are defined in the Front Matter section of each email template:
---
i18n:
congrats:
es-us: Enhorabuena!
fr-cs: Félicitations!
---
You tag a section of text for translation like so:
{{#i18n "congrats"}}Congratulations!{{/i18n}}
You'll notice that there is no English translation. That's because the default translation goes inside the helper tags. It also serves as a backup in case no other translations are provided or the requested translation isn't available.
The translation key is the text (in quotes) inside the {{#i18n}}
tag and it corresponds to the key in the i18n
section of the Front Matter. In the examples above congrats
is the translation key. For each {{#i18n}}
tag you use you must provide a translation key in the Front Matter, otherwise an error will be raised when you build the templates. However, the key can be empty if you do not have translations to provide. The following are all valid:
---
i18n:
congrats:
es-us: Enhorabuena!
---
---
i18n:
congrats:
es-us:
fr-cs:
---
---
i18n:
congrats:
---
You can specify as many translations as necessary, and each translation key can be used multiple times if necessary.