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 = () => {
|
export const useLocales = () => {
|
||||||
const i18n = useI18n();
|
const i18n = useI18n();
|
||||||
|
const { current: vuetifyLocale, isRtl } = useLocale();
|
||||||
const { isRtl } = useRtl();
|
|
||||||
const { current: vuetifyLocale } = useLocale();
|
|
||||||
|
|
||||||
const locale = computed<LocaleObject["code"]>({
|
const locale = computed<LocaleObject["code"]>({
|
||||||
get: () => i18n.locale.value,
|
get: () => i18n.locale.value,
|
||||||
|
@ -16,13 +14,17 @@ export const useLocales = () => {
|
||||||
// auto update vuetify locale
|
// auto update vuetify locale
|
||||||
watch(locale, (lc) => {
|
watch(locale, (lc) => {
|
||||||
vuetifyLocale.value = lc;
|
vuetifyLocale.value = lc;
|
||||||
});
|
const currentLocale = LOCALES.find(lc => lc.value === vuetifyLocale.value);
|
||||||
// auto update rtl
|
|
||||||
watch(vuetifyLocale, (vl) => {
|
|
||||||
const currentLocale = LOCALES.find(lc => lc.value === vl);
|
|
||||||
if (currentLocale) {
|
if (currentLocale) {
|
||||||
isRtl.value = currentLocale.dir === "rtl";
|
isRtl.value = currentLocale.dir === "rtl";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useHead({
|
||||||
|
htmlAttrs: {
|
||||||
|
lang: lc,
|
||||||
|
dir: isRtl.value ? "rtl" : "ltr",
|
||||||
|
},
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue