0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-17 16:55:12 +00:00

feat: Show popup for changing language to restart the app

This commit is contained in:
Kenny 2022-06-22 13:15:51 -04:00
parent 9c1eb74187
commit 8edab2e5b5
2 changed files with 36 additions and 5 deletions

View file

@ -1,11 +1,26 @@
<template> <template>
<div>
<v-select <v-select
v-model="selectedLang" v-model="selectedLang"
background-color="background" background-color="background"
:items="langs" :items="langs"
label="App Language" label="App Language"
solo 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> </template>
<script> <script>
@ -13,23 +28,33 @@ export default {
data() { data() {
return { return {
langs: [], langs: [],
lang: { mods: { general: { language: "" } } }, lang: { global: {}, mods: { general: { language: "" } } },
selectedLang: null, selectedLang: null,
restart: false,
//--- Required To Prvent Initial Popup ---//
userChanged: false
}; };
}, },
watch: { watch: {
//--- Update Stored Language Value ---// //--- Update Stored Language Value ---//
selectedLang: function (newVal) { 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); const langs = this.$lang(null, true);
let lang = String(); let lang = String();
for (const i in langs) { for (const i in langs) {
if (langs[i].name == newVal) { if (langs[i].name == newVal) {
lang = i; lang = i;
console.log(lang); this.lang = langs[i];
} }
} }
localStorage.setItem("language", lang); localStorage.setItem("language", lang);
this.restart = true;
}, },
//--- End Update Stored Language Value ---// //--- End Update Stored Language Value ---//
}, },
@ -43,5 +68,11 @@ export default {
this.selectedLang = this.$lang().name; this.selectedLang = this.$lang().name;
}, },
methods: {
restartApp() {
this.$router.replace("/");
}
}
}; };
</script> </script>

View file

@ -5,9 +5,9 @@ module.exports = {
home: "Home", home: "Home",
subscriptions: "Subscriptions", subscriptions: "Subscriptions",
library: "Library", library: "Library",
restart: "Restart Now", restart: "Restart",
later: "Later", 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: { index: {