import { TFunction } from 'i18next'; import moment from 'moment'; import Dayjs from 'dayjs'; import { enTranslations } from './locales'; import 'dayjs/locale/nl'; import 'dayjs/locale/ru'; import 'dayjs/locale/tr'; import 'dayjs/locale/fr'; import 'dayjs/locale/hi'; import 'dayjs/locale/it'; import 'dayjs/locale/es'; import 'dayjs/locale/en'; import { UR } from 'getstream'; import { TranslationContextValue } from '../context'; declare type Options = { DateTimeParser?: typeof Dayjs; dayjsLocaleConfigForLanguage?: Partial; debug?: boolean; disableDateTimeTranslations?: boolean; language?: string; logger?: (msg?: string) => void; translationsForLanguage?: typeof enTranslations; }; export declare type TDateTimeParser = (input?: string | number | Date) => Dayjs.Dayjs | moment.Moment; export declare type LanguageCallbackFn = (t: TFunction) => void; export declare class Streami18n { i18nInstance: import("i18next").i18n; Dayjs: null; setLanguageCallback: LanguageCallbackFn; initialized: boolean; t: TFunction; tDateTimeParser: TDateTimeParser; translations: Record>; /** * dayjs.updateLocale('nl') also changes the global locale. We don't want to do that * when user calls registerTranslation() function. So intead we will store the locale configs * given to registerTranslation() function in `dayjsLocales` object, and register the required locale * with moment, when setLanguage is called. * */ dayjsLocales: Record>; /** * Initialize properties used in constructor */ logger: (msg: string) => void; currentLanguage: string; DateTimeParser: typeof Dayjs; isCustomDateTimeParser: boolean; i18nextConfig: { debug: boolean; fallbackLng: false; interpolation: { escapeValue: boolean; }; keySeparator: false; lng: string; nsSeparator: false; parseMissingKeyHandler: (key: string) => string; }; /** * Contructor accepts following options: * - language (String) default: 'en' * Language code e.g., en, tr * * - translationsForLanguage (object) * Translations object. Please check src/i18n/en.json for example. * * - disableDateTimeTranslations (boolean) default: false * Disable translations for datetimes * * - debug (boolean) default: false * Enable debug mode in internal i18n class * * - logger (function) default: () => {} * Logger function to log warnings/errors from this class * * - dayjsLocaleConfigForLanguage (object) default: 'enConfig' * [Config object](https://momentjs.com/docs/#/i18n/changing-locale/) for internal moment object, * corresponding to language (param) * * - DateTimeParser (function) Moment or Dayjs instance/function. * Make sure to load all the required locales in this Moment or Dayjs instance that you will be provide to Streami18n * * @param {*} options */ constructor(options?: Options); /** * Initializes the i18next instance with configuration (which enables natural language as default keys) */ init(): Promise; localeExists: (language: string) => boolean; validateCurrentLanguage: () => void; /** Returns an instance of i18next used within this class instance */ geti18Instance: () => import("i18next").i18n; /** Returns list of available languages. */ getAvailableLanguages: () => string[]; /** Returns all the translation dictionary for all inbuilt-languages */ getTranslations: () => Record>; /** * Returns current version translator function. */ getTranslators(): Promise; /** * Register translation */ registerTranslation(language: string, translation: typeof enTranslations, customDayjsLocale?: Partial): void; addOrUpdateLocale(key: string, config: Partial): void; /** * Changes the language. */ setLanguage(language: string): Promise; registerSetLanguageCallback(callback: LanguageCallbackFn): void; } export {}; //# sourceMappingURL=Streami18n.d.ts.map