Localization Scripting
Provide script oriented APIs to manipulate translations |
Type | JAR |
Category | |
Developed by | |
Rating | |
License | GNU Lesser General Public License 2.1 |
Table of contents
Description
The identifier of the Localization Script Service is localization.
A translation corresponding to a key can be obtained by calling:
The printable translation of a defined property is obtained by calling:
As with the old MessageTool, parametrized translations can be obtained with:
where parameters is a list of parameter values. The format of the translation is the one accepted by the MessageFormat class.
It's also possible to choose the syntax in which the translation message is going to be rendered using:
XWiki 5.1+
the default being plain/1.0.
XWiki 9.0+
You can also pass the Locale to search for (instead of using the current Locale):
Note that it will search for a key in the parent locale also (e.g. 'fr') if it cannot find the key in the given locale (e.g. 'fr_FR').
XWiki 10.2+
It's possible to pass a list of keys to test one by one until one is found.
It's possible to add on demand translation bundles for the current execution by indicating their type and identifier like in:
XWiki 5.0M1+
You can retrieve the current Locale:
XWiki 14.1+
and the configured default Locale: