mozilla

L10n API

Non-standard
This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

The L10n API provides access to localization resources (e.g. translated strings) and localization events, as well as information about the current language. It is accessible through the navigator.mozL10n property.

Properties

L10n.language.code
Returns the code of the currently active language.
L10n.language.direction
Returns the direction of the currently active language.
L10n.readyState
Returns the current state of the L10n context (loading or complete).

Methods

L10n.get()
Returns the translation for the given identifier.
L10n.formatValue()
An asynchronous equivalent of L10n.get. Returns a Promise which resolves to the translation for the given identifier.
L10n.setAttributes()
Sets data-l10n-id and data-l10n-args attributes on an element.
L10n.ready()
A callback that executes at least once, when the L10n context is or becomes ready (when L10n.readyState is complete) and each time the language is changed in the future.
L10n.once()
A callback that executes exactly once, when the L10n context is or becomes ready (when L10n.readyState is complete).

Specification

L10n is not part of any specification; note however that this API will be replaced by L20n in the future.

See also

Document Tags and Contributors

Contributors to this page: teoli, stasm, chrisdavidmills
Last updated by: teoli,