Defining the location of the I18N catalogue
In types.xml, add an i18n child element to the resource element defining your document type. Within the i18n element, write the absolute path to the directory containing your i18n catalogue files.
<resource name="text" label="types:cms.types.label.text" i18n:attr="label"> <schema>context://types/text/text.xsd</schema> <template>context://types/text/text.xml</template> <css>context://types/text/text.css</css> <layout>context://types/text/layout.xml</layout> <bl>context://types/text/business_logic.xml</bl> <i18n>context://types/text/i18n</i18n> </resource>
Defining the I18N keys prefix
In your business logic file, define prefixes for your I18N keys. There are two prefixes to be defined: one for the field labels, and one for the field help messages. For example:
<i18n> <field-prefix>cms.demo.fields</field-prefix> <help-prefix>cms.demo.help</help-prefix> </i18n>
Creating the I18N catalogues
Create messages_xx.xml files for each language you want to support, replacing 'xx' with the corresponding locale code. In the catalogue, define messages for all your fields. The keys consist of the prefix you defined in the business logic + the xpath for the element with the slashes replaced by dots. So in our example the element /root/title would have the I18N key cms.demo.fields.root.title.
<catalogue xml:lang="en"> <message key="cms.demo.fields.root.title">Title</message> <message key="cms.demo.fields.root.body">Body</message> <message key="cms.demo.help.root.title">This will be the title of your web page</message> </catalogue>
You can also define custom translations for the editor's system messages (document saved, required field missing, etc.).
No labels in the layout
Remove any hardcoded label and help elements from your layout file. They are not needed anymore.