/* eslint-disable @typescript-eslint/no-empty-object-type */ /* eslint-disable @typescript-eslint/consistent-type-definitions */ /* eslint-disable @typescript-eslint/no-namespace */ import type { OmitIndexSignature, Primitive, Simplify } from 'type-fest'; import type libuiTranslations from './translations/libui.json'; interface TranslationsLike { [key: string]: TranslationsLike | { [L in Language]?: string }; } export declare namespace UserConfig { interface LanguageOptions { [key: string]: boolean; } interface Translations extends TranslationsLike {} } export type LanguageOptions = UserConfig.LanguageOptions & { en: true; fr: true; }; export type Language = keyof { [L in keyof LanguageOptions as LanguageOptions[L] extends true ? L : never]: any }; export type Translations = Simplify< OmitIndexSignature & { libui: typeof libuiTranslations; } >; export type ExtractTranslationKey = Key extends string ? T[Key] extends { [key: string]: any } ? T[Key] extends { [K in Language]?: string } ? Key : `${Key}.${ExtractTranslationKey}` : `${Key}` : never; export type TranslationNamespace = Extract; export type TranslationKey = ExtractTranslationKey; export type TranslationKeyForNamespace = Extract extends `${TNamespace}.${infer TKey}` ? TKey : never; export type TranslateFormatArgs = | Exclude[] | { [L in Language]?: Exclude[]; }; export type TranslateOptions = { args?: TranslateFormatArgs; }; export interface TranslateFunction { (key: TKey, options?: TranslateOptions): string; (translations: { [L in Language]?: string }, options?: TranslateOptions): string; } export type TranslatorType = { changeLanguage: (language: Language) => void; resolvedLanguage: Language; t: TranslateFunction; };