UNPKG

@scaleway/use-i18n

Version:
9 lines 1.1 kB
import { ReactNode } from "react"; import { BaseLocale, LocaleKeys, LocaleValue, Params, Scopes } from "international-types"; //#region src/types.d.ts type ScopedValue<Locale extends BaseLocale, Scope extends Scopes<Locale> | undefined, Key extends LocaleKeys<Locale, Scope>> = Scope extends undefined ? Locale[Key] : Locale[`${Scope}.${Key}`]; type ReactParamsObject<Value extends LocaleValue> = Record<Params<Value>[number], LocaleValue | ReactNode>; type TranslateFn<Locale extends BaseLocale> = <Key extends LocaleKeys<Locale, undefined>, Value extends LocaleValue = ScopedValue<Locale, undefined, Key>>(key: Key, ...params: Params<Value>['length'] extends 0 ? [] : [ReactParamsObject<Value>]) => string; type ScopedTranslateFn<Locale extends BaseLocale> = <Scope extends Scopes<Locale>>(scope: Scope) => <Key extends LocaleKeys<Locale, Scope>, Value extends LocaleValue = ScopedValue<Locale, Scope, Key>>(key: Key, ...params: Params<Value>['length'] extends 0 ? [] : [ReactParamsObject<Value>]) => string; //#endregion export { ReactParamsObject, ScopedTranslateFn, ScopedValue, TranslateFn };