Skip to content

I18n

Purpose

A utility to manage i18n.

Note

The default locale is EN

Methods

Binding name: p6.i18n


getText

Reads the locale pipeline entry and searches for the corresponding text in the map.

Syntax

String p6.i18n.getText(Map texts)

Note

If no entry is found, or the pipeline variable is empty, the default locale EN is used.

Note

Since 6.9.9 (cf. i18n) The string retrieved will be interpolated to inject any translation

Example
def label = [
        EN: 'English',
        FR: 'French'
]
println p6.i18n.getText(label)

getText (with locale)

Returns the corresponding text in the map matching the given locale.

Syntax

String p6.i18n.getText(Map texts, String locale)

Note

Since 6.9.9 (cf. i18n) The string retrieved will be interpolated to inject any translation

Note

If no entry is found, the default locale EN is used.

Example
def label = [
        EN: 'English',
        FR: 'French'
]
println p6.i18n.getText(label, 'FR')
// Output: French

println p6.i18n.getText(label, 'BE')
// Output: English

translate

Since 6.9.9 (cf. i18n)

Reads the locale pipeline entry and returns the corresponding translation.

Syntax

String p6.i18n.translate(String text)

Note

If no entry is found, or the pipeline variable is empty, the default locale EN is used.

Example
println p6.i18n.translate('text_unique_key')

translate (with locale)

Since 6.9.9 (cf. i18n)

Returns the translated text matching the given locale.

Syntax

String p6.i18n.translate(String text, String locale)

Note

If no entry is found, the default locale EN is used.

Example
println p6.i18n.translate('text_unique_key', 'FR')

clearCache

Since 6.9.9 (cf. i18n)

Clear the translation cache. Next use of the translation will reload the file resources

Syntax

String p6.i18n.clearCache()
Example
println p6.i18n.clearCache()