import { Plugin, type PluginReadyListener, type Runtime } from "@squide/core"; import type { i18n } from "i18next"; import { type DetectorOptions } from "i18next-browser-languagedetector"; import { type RegisterInstanceOptions } from "./i18nextInstanceRegistry.js"; export declare const i18nextPluginName = "i18-next-plugin"; export declare const I18nextResourcesLoadFailedEvent = "squide-i18next-resources-load-failed"; export interface I18nextResourcesLoadFailedEventPayload { key: string; language: string; error: unknown; } declare module "@squide/core" { interface EventMap { "squide-i18next-resources-load-failed": I18nextResourcesLoadFailedEventPayload; } } export interface i18nextPluginOptions { detection?: Omit; } export declare function findSupportedPreferredLanguage(userPreferredLanguages: string[], supportedLanguages: T[]): string | undefined; export type LanguageChangedListener = () => void; export declare class i18nextPlugin extends Plugin { #private; constructor(runtime: Runtime, supportedLanguages: T[], fallbackLanguage: T, queryStringKey: string, { detection }?: i18nextPluginOptions); /** * Registers an i18next instance. A lazy instance must be registered from a module's register function: once the * modules are registered, the call throws. A static instance can be registered at any time. * * When a `loadResources` function is provided, the instance must have been initialized (with `resources: {}` when * it holds no static resources) and the user language must have been detected. The plugin then loads the * resources of the current language right away, and the resources of any language the instance doesn't hold * when the language changes. */ registerInstance(key: string, instance: i18n, { loadResources }?: RegisterInstanceOptions): void; getInstance(key: string): i18n; detectUserLanguage(): void; get currentLanguage(): T; /** * Changes the current language of every registered instance, after loading the resources of that language into * the instances that don't hold them yet. * * The returned promise resolves once the switch is done. It rejects with an {@link I18nextResourcesLoadError} * when a load fails, in which case the language is left unchanged. When the call is superseded by a more recent * call, it resolves without switching. Called with the current language, it waits for the pending loads of that * language without notifying the listeners. Throws synchronously when the language isn't supported. */ changeLanguage(language: T): Promise; registerLanguageChangedListener(callback: LanguageChangedListener): void; removeLanguageChangedListener(callback: LanguageChangedListener): void; /** * Whether the modules are registered, every registered instance has settled the load of the current language * resources and no language switch requested with {@link changeLanguage} is still loading. A failed load counts * as settled so the application still renders. The application consults it once every other bootstrapping input * is ready, therefore a switch to the user preferred language requested from the bootstrapping route holds the * render until its resources are loaded. */ isReady(): boolean; registerReadyListener(callback: PluginReadyListener): void; removeReadyListener(callback: PluginReadyListener): void; } export declare function getI18nextPlugin(runtime: Runtime): i18nextPlugin;