Components can be used on different websites and countries. In those cases, Content can be internationalized so that it is displayed in different ways depending on the region.
To enable the internationalization of contributed content, each individual component property can have the feature enabled.
Note the Internationalized
option is checked off.
The i18n
or internationalized
keyword can be appended to the property definition.
Note the following example for a property title
:
[mynt:myComponent] > jnt:content, jmix:structuredContent
- title (string)
The resulting internationalization becomes either:
- title (string) i18n
or
- title (string) internationalized
Note that the i18n
and internationalized
keywords achieve the same result. Both enable internationalization for the given property.
As a result of this change, content of type mynt:myComponent
has a language dependent title
value.
In addition to Content, the Edit window UI labels corresponding to defined components may also be internationalized.
This is useful in cases where a multilingual editing team is a working on the same project.
The Resource Bundle files can be found in /resources/resources
.
Right-clicking Edit
on one of the available [moduleName]_[lang].properties
files opens the Studio Resource Bundle Editor for the corresponding file:
Selecting the generic [moduleName].properties
enables editing the labels for each available language:
The component property key follows this structure : {name_of_component}.{property_name}
.
For every ".
" in the name, it must be replaced with a "_
" when referenced in a resource bundle file.
For example, editing the English label title
for mynt:myComponent
:
/resources/resource/{module_name}.en.properties
mynt_myComponent.title
as the keyExample Result:
mynt_myComponent.title=desired value
In views, there is sometimes a need to display static values such as labels or messages.
Despite being static, those values can be internationalized according to the the visitor browsing language.
In views, values should not be hardcoded. Instead, a label can be referenced:
[module_name].properties
:
[unique_prefix].[label_name]=[desired_label_value]
[unique_prefix]
enables a unique identifier for label_name
. This is particularly useful when properites with the same label_name
are referenced in several properties files.
fmt:message
function:
<%@ taglib prefix="fmt” uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:message key="propertyKey"/>
Displaying a warning message to Editors:
myComponent.emptyEditorWarningMessage
.
<%@ taglib prefix="fmt” uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:message key="myComponent.emptyEditorWarningMessage"/>
definitions.cnd
, internationalize the Biography
fieldTo edit the English employee property label:
/resources/resource/[module_name].en.properties
.mynt_employee.jcr_title
as the key.Then, repeat these steps for another language and verify the results in Edit Mode.