import i18n from '@/i18n'; import zh from '@/locales/zh'; type NestedKeyOf = { [Key in keyof ObjectType & (string | number)]: ObjectType[Key] extends object ? `${Key}` | `${Key}.${NestedKeyOf}` : `${Key}` }[keyof ObjectType & (string | number)]; type TranslationKeys = NestedKeyOf; export function translate(key: K | string): string { return i18n.global.t(key.toLowerCase()); }