The mechanism of localisation for labels and messages is based on the recommendations and tools offered by the Java API. The files containing the localized resources are text "properties" files with a suffix indicating the language and possibly the country. Those files are loaded by the class ResourceBundle that will choose according to the locale the right localized strings. Here are suffix rules :
| File's name | <sous-systeme>_messages.properties |
| File's location | fr.paris.lutece.portal.resources |
| Key's structure | portal.<subsystem>.<key> |
Templates are localized on load by the method AppTemplateService.getTemplate( ... , Locale locale , ... ). Keys should be embraced and prefixed by #i18n.
Templates keys should respect this structure :
| Bundle's prefix | Template's name | Name of the label or input |
|---|---|---|
|
portal.<subsystem>. <plugin> module.<plugin>.<module>. |
manage_myobjects create_myobject |
titleObjectList labelName buttonCreate |
<h2>#i18n{document.create_document.title} « ${document_type} »</h2>
<div class="highlight-box">
<p>
<label for="document_title">#i18n{document.create_document.labelDocumentTitle}* : </label>
<input type="text" name="document_title" size="80" maxlength="255"/>
#i18n{document.create_document.helpDocumentTitle}
</p>
... In the code, the I18nService can be used to localize strings according the current locale. NB : To respect coding rules, keys must be declared as constants as follows :
private static final PROPERTY_MESSAGE_MYMESSAGE = "myplugin.myMessage";
...
String strLocalizedMessage = I18nService.getLocalizedString ( PROPERTY_MESSAGE_MYMESSAGE , locale );
...