cogProvide script oriented APIs to manipulate translations
Developed by

XWiki Development Team

0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents


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:

$services.localization.render('some.key', ['param1', 10])

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:

$services.localization.render('some.key', 'xhtml/1.0', ['param1', 10])

## since 5.1
$services.localization.render('some.key', 'xhtml/1.0')

the default being plain/1.0.

It's possible to add on demand translation bundles for the current execution by indicating their type and identifier like in:

$services.localization.use('document', 'wiki:Space.PageWithTranslations')

[since 5.0M1] Getting the current Locale:


Since 9.0RC1, most method allow passing the Locale to search for (instead of current Locale).

$services.localization.render('some.key', 'fr_FR')
Created by Thomas Mortagne on 2014/11/12 09:04

Get Connected