1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-25 16:19:43 +02:00
mealie/frontend/composables/use-locales/use-locales.ts

24 lines
495 B
TypeScript
Raw Normal View History

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