dify/web/types/i18n.d.ts
Stephen Zhou 6d0e36479b
refactor(i18n): use JSON with flattened key and namespace (#30114)
Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2025-12-29 14:52:32 +08:00

32 lines
797 B
TypeScript

import type { NamespaceCamelCase, Resources } from '../i18n-config/i18next-config'
import 'i18next'
declare module 'i18next' {
// eslint-disable-next-line ts/consistent-type-definitions
interface CustomTypeOptions {
defaultNS: 'common'
resources: Resources
keySeparator: false
}
}
export type I18nKeysByPrefix<
NS extends NamespaceCamelCase,
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 NamespaceCamelCase,
Prefix extends string = '',
> = Prefix extends ''
? keyof Resources[NS]
: Extract<keyof Resources[NS], `${Prefix}${string}`>
type A = I18nKeysWithPrefix<'billing'>