import * as React from "react"; /** * @example { de_DE: "Beispiel", pl_PL: "Przykład", en_US: "Example" } */ export type ITranslation = { [key: string]: string }; /** * @example (name) => ({ de_DE: `Hallo ${name}`, pl_PL: `Cześć ${name}`, en_US: `Hello ${name}` }) */ export type ITranslationVarFn = (...args: any[]) => ITranslation; /** * @example [ { de_DE: "Beispiel", pl_PL: "Przykład", en_US: "Example" }, ] */ export type ITranslationsArr = ITranslation[]; /** * @example { example: { de_DE: "Beispiel", pl_PL: "Przykład", en_US: "Example" }, ... } */ export type ITranslations = { [key in keyof T]: T[key] }; /** * @example { example: "Beispiel" ... } */ export type ITranslated = { [key in keyof T]: ISingleTranslated }; /** * @example "Beispiel" */ export type ISingleTranslated = T extends ITranslationsArr // Checks for array. ? string[] : T extends ITranslation // Checks for plain object. ? string : T extends ITranslationVarFn // Checks for trans method. ? (...args: Parameters) => string : string; export type ITranslationsPreset

= ITranslations

export type ITranslationsFunction = ((preset?: P) => T); export interface ILitteraProvider { preset?: ITranslationsPreset; locale?: string; setLocale?: (locale: string) => void; pattern?: RegExp; locales?: Array; } export interface ILitteraProviderProps { preset?: ITranslationsPreset; setLocale?: (locale: string) => void; pattern?: RegExp; locales?: Array; initialLocale?: string; detectLocale?: boolean; } export interface LitteraProps { locale: string; translated: ITranslated; setLocale: TSetLocale; preset?: ITranslationsPreset; } export type TSetLocale = (locale: string) => void; export type TValidateLocale = (locale: string, pattern?: RegExp) => Boolean export type TTranslate = (translations: ITranslations, locale: string, preset?: ITranslationsPreset) => ITranslated export type TTranslationsArg, P extends ITranslations

> = T | ITranslationsFunction; export function useLittera(translations: ITranslations | ((preset: P) => ITranslations), locale?: string): ITranslated; export function useLitteraMethods(): { readonly locale: string; readonly locales: string[]; readonly setLocale: TSetLocale; readonly preset: ITranslationsPreset; readonly validateLocale: TValidateLocale; readonly translate: TTranslate; } export const withLittera: (translations: ITranslations) => (Component: React.FunctionComponent>) => (props: any) => JSX.Element export const LitteraContext: React.Context export const LitteraProvider: (props: ILitteraProviderProps & {children: JSX.Element | JSX.Element[]}) => JSX.Element