/** * @license Copyright (c) 2021-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md. */ import * as React from 'react'; /** * Defines shape of all translation resources, e.g.: * { * en: { * key: "translation" * }, * pl: { * key: "tłumaczenie" * } * } */ type I18nResources = Record; /** * Defines shape of translations for a language, e.g.: * { * key: "translation" * } */ type I18nTranslations = Record; interface I18nProps { /** * Toggles debug mode. */ debug?: boolean; /** * Language code. */ lang?: string; /** * Translation resources that will be set synchronously. Resources for other languages can be still loaded on demand. */ resources?: I18nResources; } declare class Plural { lang: string; private _rules?; constructor(lang: string); /** * Checks if plural form is supported for selected language. * * @returns flag indicating if plural is supported */ static isSupported: (lang: string) => boolean; /** * Gets plural form of the translation key. * * @param key main part of the translation key * @param plural desired plural form * @returns plural form of the translation key */ getKey(key: string, plural: number): string; } interface I18nContext { /** * Debug mode. */ debug: boolean; /** * Currently selected language. */ lang: string; /** * Stored translations. */ resources: I18nResources; /** * Plural utils. */ pluralUtils: Plural; } /** * Defines React context for i18n and sets defaults. */ declare const I18nContext: React.Context; /** * `I18nProvider` component sets i18n context for all child components. */ declare const I18nProvider: React.FC; interface Props extends I18nProps { /** * Pass-through children. */ children: React.ReactNode; } interface TOpts { /** * Values to interpolate message with. */ values?: (string | number)[]; /** * Indicates which plural to use. */ plural?: number; /** * Include html tags in message. */ processTags?: T; } /** * Exposes basic translation utilities which can be used in components. * Most notably, it exposes `t` function which outputs translated message for currently selected language. * * @returns translation utils */ declare const useTranslation: () => { t: { (key: string, opts?: TOpts): string; (key: string, opts?: TOpts): React.ReactNode[]; }; lang: string; }; export { I18nContext, I18nProvider, useTranslation }; export type { I18nProps, I18nResources, I18nTranslations };