index.d.ts 1.2 KB

1234567891011121314151617181920212223
  1. import { FieldPath } from "../../utils/typescript.js";
  2. import "../../utils/index.js";
  3. import _default from "../../locale/lang/en.js";
  4. import { Language } from "../../locale/index.js";
  5. import { InjectionKey, Ref } from "vue";
  6. import { MaybeRef } from "@vueuse/core";
  7. //#region ../../packages/hooks/use-locale/index.d.ts
  8. type LocaleKeys = Exclude<FieldPath<typeof _default>, 'name' | 'el'> | (string & NonNullable<unknown>);
  9. type TranslatorOption = Record<string, string | number>;
  10. type Translator = (path: LocaleKeys, option?: TranslatorOption) => string;
  11. type LocaleContext = {
  12. locale: Ref<Language>;
  13. lang: Ref<string>;
  14. t: Translator;
  15. };
  16. declare const buildTranslator: (locale: MaybeRef<Language>) => Translator;
  17. declare const translate: (path: LocaleKeys, option: undefined | TranslatorOption, locale: Language) => string;
  18. declare const buildLocaleContext: (locale: MaybeRef<Language>) => LocaleContext;
  19. declare const localeContextKey: InjectionKey<Ref<Language | undefined>>;
  20. declare const useLocale: (localeOverrides?: Ref<Language | undefined>) => LocaleContext;
  21. //#endregion
  22. export { LocaleContext, LocaleKeys, Translator, TranslatorOption, buildLocaleContext, buildTranslator, localeContextKey, translate, useLocale };