This is the latest information. there are some jira tasks which can have an impact on the current i18n solution (more in the context of configuration than to the api).
configuration
the configuration is done in Config repository: /server/i18n:
- define the application language (change the language node)
- the fall back language is en
- the standard bundle is info.magnolia.module.admininterface.messages_en.properties
General
- We use Propertyfiles
- We use JSTL fmt tags
- Each module has his own messages bundle
JSP
Use the standard fmt JSTL Tags
examples:
<title><fmt:message key="central.title"/></title>
<fmt:message key="buttons.editfooter" var="label"/>
<cms:editButton label="$\{label}" ..
JavaSide (servlet, beans, ..)
Use the MessagesManager.getMessages(request, ...) to get the Messages or MessagesManager.get(request, ....) to get a string. The mechanism will handle the exception if the request is null.
javax.servlet.jsp.jstl.fmt.LocaleSupport
If you can provide a PageContext, you can use the static methods of this class. Our system is behaving like JSTL so you will get the same result.
Dialogs, Paragraphs
the labels, .. can define a key which is searched in this order
- info.magnolia.module.admininterface.messages_templating_custom.properties
- info.magnolia.module.admininterface.messages_templating.properties
- if not found return the label (it is not a key)
The class used in this case is TemplateMessagesUtil providing some static methods.
messages_templating and messages_templating_custom
I separated the strings, because we said that a bundle must be translated fully. in the messages_templating are our delilvered dialog, paragraph strings. If someone needs his own i18n-dialogs he will put the strings in messages_templating_custom. In this way he can have chinese-dialogs without a fully translated chinese-magnolia.
Javascript
Use the Object mgnlMessages.get(key, basename, args[]). basename and args are optional.
Keys starting with js. will be added to the mgnlMessages-Object by admintemplate/js/messages.jsp