import React from "react"; import { Rosetta as RosettaBase } from "rosetta"; declare type Key = string | number | bigint | symbol; /** * @see https://github.com/microsoft/TypeScript/pull/40336 */ declare type PropType = string extends Path ? unknown : Path extends keyof T ? T[Path] : Path extends `${infer K}.${infer R}` ? K extends keyof T ? PropType : unknown : unknown; declare type Join = T extends [] ? "" : T extends [string | number | boolean | bigint] ? `${T[0]}` : T extends [string | number | boolean | bigint, ...infer U] ? `${T[0]}${D}${Join}` : string; export interface RosettaExtended extends Omit, "t"> { /** * Inter type from property path (note: using array as path won't infer type) * @example Infer type * const title = t("title"); * const text = t("landing.title"); * @example Force type. * const text = t(["landing", "title"]); * const text = t(["landing.feature", index, "description"]); */ t

| any[]>(key: P, params?: X, lang?: string): P extends Key[] ? PropType> : P extends Key ? PropType : unknown; /** * Force or overwrite type * @example Infer type * const title = t("title"); * const text = t("landing.title"); * @example Force type. * const text = t(["landing", "title"]); * const text = t(["landing.feature", index, "description"]); */ t | any[] = Record | any[]>(key: Key | Key[], params?: X, lang?: string): F; } /** * Use instead of this internal context. */ export declare const I18nContext: React.Context | null>; /** * @example Simple * const { t } = useI18n() * const text = t("title") * @example With types * interface LocaleTable { title: string; } * const { t } = useI18n() * const text = t("title") */ export declare function useI18n(): RosettaExtended; /** * @example * import type { GetStaticProps } from "next"; * import type { I18nProps } from "next-rosetta"; * interface MyLocale { title: string } * export const getStaticProps: GetStaticProps> = async (context) => { * // ... * } */ export declare type I18nProps = { table: T; }; export declare type I18nProviderProps = I18nProps & { children?: any; }; /** * You probably want to add this at the root of your project. If you are using Next.js add it to `_app.tsx`. */ export declare function I18nProvider({ table, children }: I18nProviderProps): JSX.Element; export {};