typing.ts 574 B

12345678910111213141516171819202122232425
  1. export type SupportedLanguagesType = 'en-US' | 'zh-CN';
  2. export type ImportLocaleFn = () => Promise<{ default: Record<string, string> }>;
  3. export type LoadMessageFn = (
  4. lang: SupportedLanguagesType,
  5. ) => Promise<Record<string, string> | undefined>;
  6. export interface LocaleSetupOptions {
  7. /**
  8. * Default language
  9. * @default zh-CN
  10. */
  11. defaultLocale?: SupportedLanguagesType;
  12. /**
  13. * Load message function
  14. * @param lang
  15. * @returns
  16. */
  17. loadMessages?: LoadMessageFn;
  18. /**
  19. * Whether to warn when the key is not found
  20. */
  21. missingWarn?: boolean;
  22. }