Skip to content

Localization

A class for managing internationalization (translations) in the editor.

I18N

A class for managing translations.

I18N Methods

FunctionSignatureDescription
getLocalegetLocale(): stringReturns the current active locale.
getDefaultLocalegetDefaultLocale(): stringReturns the default locale.
getget(key: string, def?: string): stringReturns the translation for the specified key. If the translation is not found, returns the default value.

Types and Interfaces of I18N

typescript
/**
 * Structure of locale map data.
 * Key-value pairs for translation strings.
 */
export type LocaleMapData = {
 [key: string]: unknown;
};

/**
 * Interface for locale map.
 * @property code - Locale identifier code
 * @property data - Translation data for this locale
 */
export interface LocaleMap {
 code: string;
 data: LocaleMapData;
}

/**
 * Interface for I18N to manage internationalization.
 */
export interface I18N {
 getLocale(): string;
 getDefaultLocale(): string;
 get(key: string, def?: string): string;
}

Example of Using I18N

Localization

dev@priveted.com | priveted.com