@aplus-frontend/ui
Version:
26 lines (25 loc) • 715 B
JavaScript
import { get as l } from "lodash-unified";
import { unref as r, computed as c, isRef as a, ref as s, inject as m } from "vue";
import "../../locale/index.mjs";
import i from "../../locale/lang/zh-cn.mjs";
const u = (t) => (e, o) => f(e, o, r(t)), f = (t, e, o) => l(o, t, t).replace(
/\{(\w+)\}/g,
(C, n) => `${e?.[n] ?? `{${n}}`}`
), p = (t) => {
const e = c(() => r(t).name), o = a(t) ? t : s(t);
return {
lang: e,
locale: o,
t: u(t)
};
}, x = /* @__PURE__ */ Symbol("localeContextKey"), K = (t) => {
const e = t || m(x, s());
return p(c(() => e?.value || i));
};
export {
p as buildLocaleContext,
u as buildTranslator,
x as localeContextKey,
f as translate,
K as useLocale
};