This page explains in four easy steps the general procedure that is to be followed in making your module or app translatable. We assume that you have read and are familiar with the basic aspects of internationalization.
Step 1: Create a message file
For your app or module, create a message file named
<bundle-name>_<locale>.properties and save it to the
/src/main/resources/<module-name>/i18n/ directory in the module structure. If the folder doesn't exist, create it. For your app. Every app should have its own message bundle. So if your module deploys two apps, create two bundles.
Make sure that the filename corresponds to the following pattern:
Step 2: Add keys and translations to the file
Include the message keys and the translations in the
.properties file. Below is an example pattern for an app named
foobar-app with the subapps
foobar (a detail item editor). You may want to use this file as a template
.properties file for your own custom content app.
Before saving your
.properties file, make sure that the
<locale> part of the filename matches the language of the translation labels.
Step 3: Revise the messages in your bundle
For the translation to work, you must add key/value pairs for both the autogenerated keys and custom defined keys. For some standard components or sub elements such as the buttons "Cancel" and "Save", you may rely on the already existing translations in message bundles of other Magnolia modules. In the above template code, such translations are on the commented-out lines 11, 12, 13, 16, and 17. (For further information about reusing existing keys please read Generic i18n keys.)
Step 4: Check the outcome in the UI
Check the messages for all your dialogs and other elements of your app or module in the UI. Any change made to a
*.properties is applied and visible instantly.