mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
simplify plugin and include useHead attrs
This commit is contained in:
parent
88d0b466ce
commit
3d85a3cfcd
1 changed files with 9 additions and 7 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue