feat: Add dropdown for language switch

Signed-off-by: Pranav C <61551451+pranavxc@users.noreply.github.com>
This commit is contained in:
Pranav C
2021-07-15 18:31:47 +05:30
parent 5017de328d
commit 2542e79f9e
7 changed files with 369 additions and 638 deletions

View File

@@ -11,7 +11,7 @@ export default ({app, store}) => {
// This way we can use it globally in our components through this.$i18n
app.i18n = new VueI18n({
// Set the initial locale
locale: "en",
locale: store.state.windows.language,
// Set the fallback locale in case the current locale can't be found
fallbackLocale: "en",
@@ -20,14 +20,18 @@ export default ({app, store}) => {
messages: {
en: require("~/static/lang/en.json"),
zh: require("~/static/lang/zh.json"),
ja: require("~/static/lang/ja.json"),
// ja: require("~/static/lang/ja.json"),
fr: require("~/static/lang/fr.json")
}
});
store.watch(
(state) => state.windows.language,
(language) => app.i18n.locale = language
(language) => {
if (app.i18n.availableLocales.includes(language)) {
app.i18n.locale = language
}
}
);
};
/**