mirror of
https://github.com/Alvin-Zilverstand/return-youtube-dislike.git
synced 2026-12-02 19:01:21 +01:00
locale preference caching added, translation files reset
This commit is contained in:
1 parent
751d6fb7de
commit
2af93ab621
5 files changed
+229
-12
No files matched your search
@@ -50,7 +50,7 @@
|
||||
:key="index"
|
||||
link
|
||||
:class="$vuetify.lang.current === lang.locale ? 'primary--text' : ''"
|
||||
@click="$vuetify.lang.current = lang.locale"
|
||||
@click="changeLocale(lang.locale)"
|
||||
>
|
||||
<v-list-item-title v-text="lang.name"></v-list-item-title>
|
||||
</v-list-item>
|
||||
@@ -112,12 +112,17 @@ export default {
|
||||
html: "",
|
||||
},
|
||||
}),
|
||||
mounted() {
|
||||
created() {
|
||||
// fetch locale preference or browser default
|
||||
if (process.client && navigator.language) {
|
||||
this.$vuetify.lang.current = navigator.language.slice(0, 2);
|
||||
if (!("locale" in localStorage))
|
||||
this.$vuetify.lang.current = navigator.language.slice(0, 2);
|
||||
else this.$vuetify.lang.current = localStorage.locale;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
setTimeout(() => {
|
||||
// Chrome < 70 or FF < 60
|
||||
// Chrome < 70 or FF < 60 unsupported warning popup
|
||||
if (
|
||||
(this.$ua._parsed.name == "Chrome" &&
|
||||
parseInt(this.$ua._parsed.version.split(".")[0]) < 70) ||
|
||||
@@ -131,6 +136,15 @@ export default {
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
methods: {
|
||||
changeLocale(locale) {
|
||||
// reset to browser default if selection matches browser default
|
||||
if (locale == navigator.language.slice(0, 2)) localStorage.clear();
|
||||
// else save preference
|
||||
else localStorage.locale = locale;
|
||||
this.$vuetify.lang.current = locale;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user