Internationalization
Localizing the content provided by the plugin
The /config directory is the place where the localized property files are stored.
The property files are named plugin_(locale).properties : for example, plugin_fr.properties, for the French translation.
Basic localization
The basic way to access the keys in JSP pages is by initializing your bundle :
<noheto:setPluginBundle var="myPluginBundle" plugin="${plugin}" locale="${locale}" scope="request"/>
Then look for localized messages :
<noheto:message bundle="${myPluginBundle}" key="the_label_key">
<noheto:parameter value="${optional parameters if you need to customize the message}" />
</noheto:message>
Common bundle init within multiple pages
If your plugin contains multiple pages that hook on the Back-Office, it is good practice to init your bundle once :
Create a page/bov3/common/init/initBundle/initBundle_content_before.jsp
<%@page pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="/WEB-INF/c.tld" %>
<%@taglib prefix="noheto" uri="/WEB-INF/noheto.tld" %>
<noheto:skipPage test="${not pageContext.request.included}"/>
<noheto:setBundle var="myPluginBundle"
scope="request"
baseName="${plugin.bundleBaseName}"
locale="${surfer.CTSurfer.locale}"/>
Then, you will have the following method available in your BOv3 pages :
<noheto:message bundle="${myPluginBundle}" key="the_label_key"/>
Java localization in your plugins
Another way in pure Java to address the bundle could be :
// Let's retrieve from request the plugin attribute which will help us
com.noheto.plugins.IPlugin plugin;
plugin = (com.noheto.plugins.IPlugin)request.getAttribute("plugin");
// We want the display strings to be internationalized, so we need to retrieve
// a bundle. As we are in a plugin, we will use the bundle from the plugin.
// we will use the locale available from the surfer
wsnoheto.engine.CTSurfer surfer;
surfer = wsnoheto.engine.CTSurfer.from(request);
java.util.Locale surferLocale = surfer.getLocale();
String pluginBundleBaseName = plugin.getBundleBaseName();
noheto.resource.ResourceBundle pluginBundle;
pluginBundle = noheto.resource.ResourceFactory.getBundle(pluginBundleBaseName, surferLocale);
String ourLabel = pluginBundle.getString("the_label_key");
Javascript messages and strings localization in your plugins
If you want to localize some messages in the Javascript, you can use the following code that will display an information message on top of the screen:
var message = boi18n.getMessage({
"bundleName": "<noheto:str value="${plugin.bundleBaseName}" escapeJs="true" />",
"key": "the_label_key",
"params" : [ your parameters if you need to customize the message ]
});
boInfo.clear().setTitle( message ).show();
Localizing the Info descriptions
The "Info" section gives general information about the plugin and is likely to be localized in a multilingual environment
If you need to localize in multiple languages the information description, you can create new keys in a "plugin_(locale).properties" file in the /config directory of your plugin.
Keys for a specific information should follow this pattern : info.tag_to_be_translated
For example : for an english (en) translation of short description (shortdescription) :
create the <plugin>/config/plugin_en.properties
populate it with info.shortdescription = "This is my short description"
Localizing the Parameters descriptions
If you need to localize in multiple languages the parameter description, you can create new keys in a "plugin_(locale).properties" file in the /config directory of your plugin.
Keys for a specific parameter name should follow this pattern : parameter_<name>_description
For example : for an english (en) translation of mystring parameter :
create the <plugin>/config/plugin_en.properties
populate it with parameter_mystring_description = "This is my parameter description"