Locale-aware message lookup and translation utilities.
This module provides a lightweight localization layer for xeokit components,
allowing UI text to be defined once and rendered in different languages at runtime.
Translations are keyed by stable identifiers (for example "NavCube.front") and
resolved based on the currently active locale.
The service is designed for:
UI widgets that need dynamic language switching
Centralized management of translated strings
Incremental loading or replacement of translation bundles
Installation
npminstall@xeokit/sdk
Usage
The example below shows how to create a LocaleService
with English, Māori, and French translations for a NavCube widget.
The following keys are used by the NavCube:
"NavCube.front"
"NavCube.back"
"NavCube.top"
"NavCube.bottom"
"NavCube.left"
"NavCube.right"
These keys are resolved against the active locale. For example, when the locale
is set to "fr", "NavCube.back" resolves to "Arrière".
LocaleService emits an update event whenever the active locale changes or new
messages are loaded. This allows UI components to re-render automatically.
xeokit Localization Service
Locale-aware message lookup and translation utilities.
This module provides a lightweight localization layer for xeokit components, allowing UI text to be defined once and rendered in different languages at runtime. Translations are keyed by stable identifiers (for example
"NavCube.front") and resolved based on the currently active locale.The service is designed for:
Installation
Usage
The example below shows how to create a LocaleService with English, Māori, and French translations for a NavCube widget.
The following keys are used by the NavCube:
"NavCube.front""NavCube.back""NavCube.top""NavCube.bottom""NavCube.left""NavCube.right"These keys are resolved against the active locale. For example, when the locale is set to
"fr","NavCube.back"resolves to"Arrière".Switching locales at runtime
Loading additional translations
New message bundles can be merged in at any time, without recreating the service:
Clearing translations
Reacting to locale updates
LocaleServiceemits an update event whenever the active locale changes or new messages are loaded. This allows UI components to re-render automatically.