mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-21 20:35:42 -04:00
chore: Nuxt 4 upgrade (#7426)
This commit is contained in:
35
frontend/app/composables/use-locales/use-locales.ts
Normal file
35
frontend/app/composables/use-locales/use-locales.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { LocaleObject } from "@nuxtjs/i18n";
|
||||
import { LOCALES } from "./available-locales";
|
||||
import { useGlobalI18n } from "../use-global-i18n";
|
||||
|
||||
export const useLocales = () => {
|
||||
const i18n = useGlobalI18n();
|
||||
const { current: vuetifyLocale } = useLocale();
|
||||
|
||||
const locale = computed<LocaleObject["code"]>({
|
||||
get: () => i18n.locale.value,
|
||||
set(value) {
|
||||
i18n.setLocale(value);
|
||||
},
|
||||
});
|
||||
|
||||
function updateLocale(lc: LocaleObject["code"]) {
|
||||
vuetifyLocale.value = lc;
|
||||
}
|
||||
|
||||
// auto update vuetify locale
|
||||
watch(locale, (lc) => {
|
||||
updateLocale(lc);
|
||||
});
|
||||
|
||||
// set initial locale
|
||||
if (i18n.locale.value) {
|
||||
updateLocale(i18n.locale.value);
|
||||
};
|
||||
|
||||
return {
|
||||
locale,
|
||||
locales: LOCALES,
|
||||
i18n,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user