Skip to content
This repository has been archived by the owner on Oct 31, 2022. It is now read-only.

Commit

Permalink
feat: ✨ Show popup for changing language to restart the app
Browse files Browse the repository at this point in the history
  • Loading branch information
Frontesque committed Jun 22, 2022
1 parent 9c1eb74 commit 8edab2e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
37 changes: 34 additions & 3 deletions NUXT/components/Settings/language.vue
Original file line number Diff line number Diff line change
@@ -1,35 +1,60 @@
<template>
<div>
<v-select
v-model="selectedLang"
background-color="background"
:items="langs"
label="App Language"
solo
></v-select>
/>

<v-dialog v-model="restart" width="500">
<v-card class="rounded-lg" :class=" $vuetify.theme.dark ? 'background lighten-1' : 'background darken-1' " >
<v-card-title class="text-h5">{{ lang.global.restart }}</v-card-title>
<v-card-text>{{ lang.global.settingRestart }}</v-card-text>
<v-divider />
<v-card-actions>
<v-spacer></v-spacer>
<v-btn text @click="restart = false">{{ lang.global.later }}</v-btn>
<v-btn color="primary" text @click="restartApp()">{{ lang.global.restart }}</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>

<script>
export default {
data() {
return {
langs: [],
lang: { mods: { general: { language: "" } } },
lang: { global: {}, mods: { general: { language: "" } } },
selectedLang: null,
restart: false,
//--- Required To Prvent Initial Popup ---//
userChanged: false
};
},
watch: {
//--- Update Stored Language Value ---//
selectedLang: function (newVal) {
//--- Required To Prvent Initial Popup ---//
if (this.userChanged == false) return this.userChanged = true;
//--- Change Lang Stuff ---//
const langs = this.$lang(null, true);
let lang = String();
for (const i in langs) {
if (langs[i].name == newVal) {
lang = i;
console.log(lang);
this.lang = langs[i];
}
}
localStorage.setItem("language", lang);
this.restart = true;
},
//--- End Update Stored Language Value ---//
},
Expand All @@ -43,5 +68,11 @@ export default {
this.selectedLang = this.$lang().name;
},
methods: {
restartApp() {
this.$router.replace("/");
}
}
};
</script>
4 changes: 2 additions & 2 deletions NUXT/plugins/languages/english.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module.exports = {
home: "Home",
subscriptions: "Subscriptions",
library: "Library",
restart: "Restart Now",
restart: "Restart",
later: "Later",
settingRestart: "Changing this setting requires the app to restart for the settings to be applied."
settingRestart: "Modifying this setting requires the app to restart for the changes to be applied."
},

index: {
Expand Down

0 comments on commit 8edab2e

Please sign in to comment.