remove rtl handling from locale plugin

This commit is contained in:
Michael Genson 2025-07-20 19:36:13 +00:00
commit d3d7769f81

View file

@ -3,7 +3,7 @@ import { LOCALES } from "./available-locales";
export const useLocales = () => { export const useLocales = () => {
const i18n = useI18n(); const i18n = useI18n();
const { current: vuetifyLocale, isRtl } = useLocale(); const { current: vuetifyLocale } = useLocale();
const locale = computed<LocaleObject["code"]>({ const locale = computed<LocaleObject["code"]>({
get: () => i18n.locale.value, get: () => i18n.locale.value,
@ -11,22 +11,21 @@ export const useLocales = () => {
i18n.setLocale(value); i18n.setLocale(value);
}, },
}); });
// auto update vuetify locale
watch(locale, (lc) => { function updateLocale(lc: LocaleObject["code"]) {
vuetifyLocale.value = lc; vuetifyLocale.value = lc;
const currentLocale = LOCALES.find(lc => lc.value === vuetifyLocale.value);
if (currentLocale) {
isRtl.value = currentLocale.dir === "rtl";
} }
useHead({ // auto update vuetify locale
htmlAttrs: { watch(locale, (lc) => {
lang: lc, updateLocale(lc);
dir: isRtl.value ? "rtl" : "ltr",
},
})
}); });
// set initial locale
if (i18n.locale.value) {
updateLocale(i18n.locale.value);
};
return { return {
locale, locale,
locales: LOCALES, locales: LOCALES,