1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-31 11:09:40 +02:00
mealie/frontend/composables/use-locales/use-locales.ts

27 lines
649 B
TypeScript
Raw Normal View History

import { computed, useContext } from "@nuxtjs/composition-api";
import { LOCALES } from "./available-locales";
export const useLocales = () => {
const { i18n, $vuetify } = useContext();
const locale = computed<string>({
get() {
$vuetify.lang.current = i18n.locale; // dirty hack
return i18n.locale;
},
set(value) {
i18n.setLocale(value);
$vuetify.lang.current = value; // this does not persist after window reload :-(
// Reload the page to update the language - not all strings are reactive
window.location.reload();
},
});
return {
locale,
locales: LOCALES,
i18n,
};
};