Magnolia 5.4 reached end of life on November 15, 2018. This branch is no longer supported, see End-of-life policy.
This page describes selected best practices within the context of i18n API.
Provide a message bundle in your module. It makes translation easier. A translator can work with a plain text file and doesn't need to touch the code. A message bundle is a collection of .properties
files. Each file contains key-value pairs of translated user interface text such as labels and messages. The keys in all .properties
files of the same bundle are identical but the values are language specific translations.
We recommend the following i18n filename patterns, for apps and modules, respectively:
app-<app-name>-messages_<locale>.properties
module-<module name>-messages_<locale>.properties
Make sure the locale is correct. Magnolia follows the Java locale notation.
*.properties
into ./<module-name>/i18n/
Keep your message bundles in the following folders:
src/main/resources/<module-name>/i18n/
(Maven module development) or in<magnolia.resources.dir>/<module-name>/i18n/
(light development).Whenever possible (see here for more details and restrictions), use generic, i.e. shorter i18n keys. The shorter the form, the more modules will exist where the key can be instantly reused.
Use UTF-8 character encoding in .properties
files.
Example: Message files in the Travel Demo
module-travel-demo-backend_en.properties
(user interface labels)module-travel-demo-frontend_en.properties
(template labels)