UNPKG

@readium/shared

Version:

Shared models to be used across other Readium projects and implementations in Typescript

46 lines (45 loc) 1.42 kB
export interface L10nString { compact: string; descriptive: string; } type LocaleData = Record<string, any>; declare class LocalizationImpl { private static instance; private currentLocaleCode; private locale; private availableLocales; private constructor(); static getInstance(): LocalizationImpl; /** * Registers a new locale or updates an existing one * @param localeCode BCP 47 language code (e.g., 'en', 'fr-FR') * @param localeData The locale data to register */ registerLocale(localeCode: string, localeData: LocaleData): void; /** * Sets the current locale by language code * @param localeCode BCP 47 language code (e.g., 'en', 'fr-FR') * @returns boolean indicating if the locale was set successfully */ setLocale(localeCode: string): boolean; /** * Gets the current locale code (BCP 47) */ getCurrentLocale(): string; /** * Gets a list of available locale codes */ getAvailableLocales(): string[]; private getNestedValue; /** * Gets a localized string by key * @param key The key for the string to retrieve * @returns The localized string as a [L10nString], or an empty string if not found */ getString(key: string): L10nString; } /** * The singleton instance of the [Localization] class. */ export declare const Localization: LocalizationImpl; export {};