import { JioTranslateOptions, JioTranslatePlugin, DevCredentials, TFnType, DefaultParamType, TranslationKey } from './types'; declare function createJioTranslate(options: JioTranslateOptions): Readonly<{ /** * Listen to jiotranslate events. */ on: import("./types").JioTranslateOn; /** * Listen for specific namespaces changes. * * ``` * const sub = jiotranslate.onUpdate(handler) * * // subscribe to selected namespace * sub.subscribeNs(['common']) * * // unsubscribe * sub.unsubscribe() * ``` */ onNsUpdate: (handler: import("./types").Listener) => import("./types").SubscriptionSelective; /** * Turn off/on events emitting. Is on by default. */ setEmitterActive: (active: boolean) => void; /** * @return current language if set. */ getLanguage: () => string | undefined; /** * `pendingLanguage` represents language which is currently being loaded. * @return current `pendingLanguage` if set. */ getPendingLanguage: () => string | undefined; /** * Change current language. * - if not running sets `pendingLanguage`, `language` to the new value * - if running sets `pendingLanguage` to the value, fetches necessary data and then changes `language` * * @return Promise which is resolved when `language` is changed. */ changeLanguage: (language: string) => Promise; /** * Temporarily change translation in cache. * @return object with revert method. */ changeTranslation: (descriptor: import("./types").CacheDescriptor, key: string, value: string) => { revert(): void; }; /** * Adds namespace(s) list of active namespaces. And if jiotranslate is running, loads required data. */ addActiveNs: (ns: import("./types").NsFallback, forget?: boolean | undefined) => Promise; /** * Remove namespace(s) from active namespaces. * * jiotranslate internally counts how many times was each active namespace added, * so this method will remove namespace only if the counter goes down to 0. */ removeActiveNs: (ns: import("./types").NsFallback) => void; /** * Manually load multiple records from `Backend` (or `DevBackend` when in dev mode) * * It loads data together and adds them to cache in one operation, to prevent partly loaded state. */ loadRecords: (descriptors: import("./types").CacheDescriptor[]) => Promise; /** * Manually load record from `Backend` (or `DevBackend` when in dev mode) */ loadRecord: (descriptor: import("./types").CacheDescriptor) => Promise; /** * */ addStaticData: (data: import("./types").JioTranslateStaticData | undefined) => void; /** * Get record from cache. */ getRecord: (descriptor: import("./types").CacheDescriptor) => import("./types").TranslationsFlat | undefined; /** * Get all records from cache. */ getAllRecords: () => { data: import("./types").TranslationsFlat; language: string; namespace: string; }[]; /** * @param ns optional list of namespaces that you are interested in * @return `true` if there are data that need to be fetched. */ isLoaded: (ns?: import("./types").NsFallback) => boolean; /** * Returns records needed for instance to be `loaded` */ getRequiredRecords: (lang?: string | undefined, ns?: import("./types").NsFallback) => import("./types").CacheDescriptor[]; /** * @return `true` if jiotranslate is loading initial data (triggered by `run`). */ isInitialLoading: () => boolean; /** * @param ns optional list of namespaces that you are interested in * @return `true` if jiotranslate is loading some translations for the first time. */ isLoading: (ns?: import("./types").NsFallback) => boolean; /** * @param ns optional list of namespaces that you are interested in * @return `true` if jiotranslate is fetching some translations. */ isFetching: (ns?: import("./types").NsFallback) => boolean; /** * @return `true` if jiotranslate is running. */ isRunning: () => boolean; /** * Changes internal state to running: true and loads initial files. * Runs runnable plugins mainly Observer if present. */ run: () => Promise; /** * Changes internal state to running: false and stops runnable plugins. */ stop: () => void; /** * Returns translated and formatted key. * If Observer is present and jiotranslate is running, wraps result to be identifiable in the DOM. */ t: TFnType; /** * Highlight keys that match selection. */ highlight: import("./types").HighlightInterface; /** * Find positions of keys in the DOM. */ findPositions: import("./types").FindPositionsInterface; /** * @return current jiotranslate options. */ getInitialOptions: () => { apiUrl?: string | undefined; apiKey?: string | undefined; projectId?: string | number | undefined; language?: string | undefined; defaultLanguage?: string | undefined; availableLanguages?: string[] | undefined; fallbackLanguage?: import("./types").FallbackLanguageOption; ns?: string[] | undefined; fallbackNs?: import("./types").FallbackGeneral; defaultNs: string; staticData?: import("./types").JioTranslateStaticData | undefined; observerType: "invisible" | "text"; observerOptions: import("./types").ObserverOptionsInternal; onFormatError: import("./types").OnFormatError; onTranslationMissing: import("./types").MissingTranslationHandler; fetch: import("./types").FetchFn; tagNewKeys?: string[] | undefined; dynamicScanningEnable?: boolean | undefined; }; /** * jiotranslate is in dev mode if `DevTools` plugin is used and `apiKey` + `apiUrl` are specified. * @return `true` if jiotranslate is in dev mode. */ isDev: () => boolean; /** * Wraps translation if there is `Observer` plugin */ wrap: (params: import("./types").WrapperWrapProps) => string | undefined; /** * Unwrap translation */ unwrap: (text: string) => import("./types").Unwrapped; /** * Override creadentials passed on initialization. * * When called in running state, jiotranslate stops and runs again. */ overrideCredentials(credentials: DevCredentials): void; /** * Add jiotranslate plugin after initialization. * * When called in running state, jiotranslate stops and runs again. */ addPlugin(plugin: JioTranslatePlugin | undefined): void; /** * Updates options after instance creation. Extends existing options, * so it only changes the fields, that are listed. * * When called in running state, jiotranslate stops and runs again. */ updateOptions(options?: JioTranslateOptions): void; }>; export type JioTranslateInstance = Omit, 't'> & { t: TFnType; }; export type JioTranslateChainer = { /** * Add plugin, plugins are applied when `init` method is called. */ use: (plugin: JioTranslatePlugin | undefined) => JioTranslateChainer; /** * Update default options before jiotranslate is initialized. */ updateDefaults: (options: JioTranslateOptions) => JioTranslateChainer; /** * Initialize jiotranslate options and apply plugins * @returns jiotranslate instance */ init(options?: JioTranslateOptions): JioTranslateInstance; }; /** * jiotranslate chainable constructor. * * Usage: * ``` * const jiotranslate = JioTranslate().use(...).init(...) * ``` */ export declare const JioTranslateCore: () => JioTranslateChainer; export {};