About globalization
The context can also store locale information for globalization. The locale can be defined through the deployment descriptor or through the API.
How to define a context locale through the deployment descriptor
The following example illustrates how you can customize the context locale in the deployment descriptor file:
<locale>
<language>fr</language>
<country>FR</country>
</locale>
where:
language is a lowercase two-letter ISO-639 code.
country is an uppercase two-letter ISO-3166 code.
See java.util.Locale for more information on locale arguments.
How to define a context locale through the API
The following code shows how to create a context with the French locale:
IlpContext context = new IltDefaultContext(Locale.FRENCH);
How to create a localized version of JViews TGO resources
By default, JViews TGO is localized for the en_US locale. To create a localized version for another language, do the following:
1. Extract the following property files from jviews-tgo-all.jar :
ilog/cpl/messages/EquipmentMessages.properties ilog/tgo/messages/JTGOMessages.properties ilog/cpl/messages/NetworkMessages.properties ilog/cpl/messages/TableMessages.properties 2. Create a new localized version of these files.
Observe the naming conventions for localized property files as defined in java.util.PropertyResourceBundle.
3. Make sure that the localized files are accessible to JViews TGO by adding them to the application classpath.
How to access localized resources using the API
The following code extract shows how you can access the JViews TGO resource bundle and retrieve its messages according to the locale that is currently set in your application context:
Locale locale = context.getLocale();
ResourceBundle bundle =
IlpI18NUtil.GetResourceBundle("ilog.tgo.messages.JTGOMessages", locale,
"JViews TGO");
String value = bundle.getString("ilog.tgo.Alarm_Critical");
How to access localized resources using CSS
You can also retrieve localized resources from a CSS configuration file.
To do so, use the CSS function
'resource' (
IlpResourceFunction) as illustrated below:
object."ilog.tgo.model.IltAlarm/perceivedSeverity"[perceivedSeverity=Critical]
{
label : '@|resource("ilog.tgo.messages.JTGOMessages",
"ilog.tgo.Alarm_Critical", "Critical")';
}
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.