simplify plugin and include useHead attrs

This commit is contained in:
Michael Genson 2025-07-20 18:38:09 +00:00
commit 3d85a3cfcd

View file

@ -3,9 +3,7 @@ import { LOCALES } from "./available-locales";
export const useLocales = () => {
const i18n = useI18n();
const { isRtl } = useRtl();
const { current: vuetifyLocale } = useLocale();
const { current: vuetifyLocale, isRtl } = useLocale();
const locale = computed<LocaleObject["code"]>({
get: () => i18n.locale.value,
@ -16,13 +14,17 @@ export const useLocales = () => {
// auto update vuetify locale
watch(locale, (lc) => {
vuetifyLocale.value = lc;
});
// auto update rtl
watch(vuetifyLocale, (vl) => {
const currentLocale = LOCALES.find(lc => lc.value === vl);
const currentLocale = LOCALES.find(lc => lc.value === vuetifyLocale.value);
if (currentLocale) {
isRtl.value = currentLocale.dir === "rtl";
}
useHead({
htmlAttrs: {
lang: lc,
dir: isRtl.value ? "rtl" : "ltr",
},
})
});
return {