Manages localization and internationalization settings for the Creative Editor SDK.
The InternationalisationAPI provides methods to get and set the current locale, as well as add custom translations for the editor interface.
Constructors#
Constructor#
InternationalizationAPI
InternationalizationAPI
Localization#
Methods for managing locale settings and custom translations within the editor.
getLocale()#
Gets the currently active locale.
Returns#
string
The currently set locale as a string, or the fallback locale if none is set.
Signature#
getLocale(): string
setLocale()#
Sets the active locale for the editor interface.
This will not check whether translations for the given locale are available.
Parameters#
Parameter | Type | Description |
---|---|---|
locale | string | The locale string to set as active (e.g., ‘en’, ‘de’, ‘fr’). |
Returns#
void
setTranslations()#
Adds custom translations for the editor interface.
This method allows you to provide custom translations that will be used by the editor interface. Translations are organized by locale and can override or extend the default editor translations.
Parameters#
Parameter | Type | Description |
---|---|---|
definition | Partial <Record <string , Partial <Translations >>> | An object mapping locale strings to translation objects. |
Returns#
void
Example#
setTranslations({ en: { presets: { scene: ... } }})
Signature#
setTranslations(definition: Partial<Record<string, Partial<Translations>>>): void
getTranslations()#
Retrieves the translations for the specified locales.
This method returns the translations for the given locales, or all available translations if no specific locales are provided.
Parameters#
Parameter | Type | Description |
---|---|---|
locales? | string [] | An optional array of locale strings to retrieve translations for. |
Returns#
Partial
<Record
<string
, Partial
<Translations
>>>
An object mapping locale strings to their respective translations.
Signature#
getTranslations(locales?: string[]): Partial<Record<string, Partial<Translations>>>
translate()#
Translates a key or array of keys to the current locale.
This method retrieves the translation for the given key(s) in the currently active locale. When an array of keys is provided, the first key that has a translation will be used. If no translation is found for any of the provided keys, the last key in the array (or the single key if a string is provided) will be returned as the fallback value.
Parameters#
Parameter | Type | Description |
---|---|---|
key | string | string [] |
Returns#
string
The translated string for the key in the current locale, or the key itself if no translation is found.
Example#
// Single keyconst translation = cesdk.i18n.translate('common.save');// Returns: "Save" (if translation exists) or "common.save" (if not found)
// Array of keys (fallback)const translation = cesdk.i18n.translate(['specific.save', 'common.save']);// Tries 'specific.save' first, then 'common.save'// Returns the first found translation or "common.save" if neither exists
Signature#
translate(key: string | string[]): string