dify/web/types/i18n.d.ts
Stephen Zhou 4e0a7a7f9e
chore: fix type for useTranslation in #i18n (#32134)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-09 16:42:53 +08:00

29 lines
701 B
TypeScript

import type { Namespace, Resources } from '../i18n-config/resources'
import 'i18next'
declare module 'i18next' {
// eslint-disable-next-line ts/consistent-type-definitions
interface CustomTypeOptions {
resources: Resources
keySeparator: false
}
}
export type I18nKeysByPrefix<
NS extends Namespace,
Prefix extends string = '',
> = Prefix extends ''
? keyof Resources[NS]
: keyof Resources[NS] extends infer K
? K extends `${Prefix}${infer Rest}`
? Rest
: never
: never
export type I18nKeysWithPrefix<
NS extends Namespace,
Prefix extends string = '',
> = Prefix extends ''
? keyof Resources[NS]
: Extract<keyof Resources[NS], `${Prefix}${string}`>