2024-08-02 18:19:39 +08:00
|
|
|
import { computed, inject } from 'vue';
|
|
|
|
import { dateEnUS, enUS } from "../locales/index.mjs";
|
2024-01-29 09:26:07 +08:00
|
|
|
import { configProviderInjectionKey } from "../config-provider/src/context.mjs";
|
|
|
|
export default function useLocale(ns) {
|
|
|
|
const {
|
|
|
|
mergedLocaleRef,
|
|
|
|
mergedDateLocaleRef
|
|
|
|
} = inject(configProviderInjectionKey, null) || {};
|
|
|
|
const localeRef = computed(() => {
|
|
|
|
var _a, _b;
|
|
|
|
return (_b = (_a = mergedLocaleRef === null || mergedLocaleRef === void 0 ? void 0 : mergedLocaleRef.value) === null || _a === void 0 ? void 0 : _a[ns]) !== null && _b !== void 0 ? _b : enUS[ns];
|
|
|
|
});
|
|
|
|
const dateLocaleRef = computed(() => {
|
|
|
|
var _a;
|
|
|
|
return (_a = mergedDateLocaleRef === null || mergedDateLocaleRef === void 0 ? void 0 : mergedDateLocaleRef.value) !== null && _a !== void 0 ? _a : dateEnUS;
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
dateLocaleRef,
|
|
|
|
localeRef
|
|
|
|
};
|
|
|
|
}
|