mealie/frontend/composables/use-locales/use-locales.ts
Hayden 50a67f9301
Feature/auto generate crowdin data (#1071)
* add translated key

* update code generation for crowdin generation

* use composition api and minor styling changes
2022-03-19 16:33:55 -08:00

23 lines
495 B
TypeScript

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,
};
};