index.d.ts 1.1 KB

123456789101112131415161718
  1. import English from 'element-plus/es/locale/lang/en';
  2. import type { MaybeRef } from '@vueuse/core';
  3. import type { InjectionKey, Ref } from 'vue';
  4. import type { FieldPath } from 'element-plus/es/utils';
  5. import type { Language } from 'element-plus/es/locale';
  6. export type LocaleKeys = Exclude<FieldPath<typeof English>, 'name' | 'el'> | (string & NonNullable<unknown>);
  7. export type TranslatorOption = Record<string, string | number>;
  8. export type Translator = (path: LocaleKeys, option?: TranslatorOption) => string;
  9. export type LocaleContext = {
  10. locale: Ref<Language>;
  11. lang: Ref<string>;
  12. t: Translator;
  13. };
  14. export declare const buildTranslator: (locale: MaybeRef<Language>) => Translator;
  15. export declare const translate: (path: LocaleKeys, option: undefined | TranslatorOption, locale: Language) => string;
  16. export declare const buildLocaleContext: (locale: MaybeRef<Language>) => LocaleContext;
  17. export declare const localeContextKey: InjectionKey<Ref<Language | undefined>>;
  18. export declare const useLocale: (localeOverrides?: Ref<Language | undefined>) => LocaleContext;