import { LangContextValue } from 'fastapi-rtk/contexts'; import { i18n, InitOptions } from '../../../../.external/lib/i18next'; import { PropsWithChildren, ProviderProps } from 'react'; /** A single MRT (Mantine React Table) localization resource: a flat map of localization keys to translated strings. Local so `api` has no `mantine-react-table` type dependency; the web grid re-types it to `MRT_Localization` at the consumer boundary. */ export type MRTLocalization = Record; /** A map of MRT localization resources keyed by language code. */ export type MRTLocalizationMap = { [locale: string]: Partial; }; export interface GetI18nProps { /** The props for `i18n.init`. */ initProps?: InitOptions; /** A function that takes the i18n instance and returns an i18n instance. */ callback?: i18n | ((i18n: i18n) => i18n); /** The translations to be used. E.g. `{ en: { key: 'value' }, de: { key: 'wert' } }`. */ translations?: { [locale: string]: { [key: string]: string; }; }; } export interface LangProps { /** The i18n instance to be used for translations. If not provided, it will use `getI18n` function from fastapi-rtk. */ i18n?: i18n; /** The props to pass to the `getI18n` function if `i18n` is not provided. */ getI18nProps?: GetI18nProps; /** The language to be used for translations. If not provided, defaults to language from local storage or `en`. */ lang?: string | ((i18n: i18n) => string); /** The localization resources for the MRT (Mantine React Table). */ MRTLocalization?: MRTLocalizationMap; } type InnerLangProviderProps = Omit, 'value' | 'children'>; export type InnerLangContextProviderProps = PropsWithChildren<{ /** The localization resources for the MRT (Mantine React Table). */ MRTLocalization?: MRTLocalizationMap; } & InnerLangProviderProps>; export type LangContextProviderProps = PropsWithChildren<{ /** The props for the language context. */ langProps?: LangProps; /** Additional props forwarded to the inner language context provider. */ props?: InnerLangProviderProps; }>; export type { LangContextValue };