Use user's system language by default.

This commit is contained in:
FireMasterK 2021-09-23 23:57:26 +01:00 committed by Kavin
parent 4e4ecd1fba
commit 58e69da0c2
3 changed files with 15 additions and 3 deletions

View File

@ -62,7 +62,7 @@ export default {
const App = this; const App = this;
(async function() { (async function() {
const locale = App.getPreferenceString("hl", "en"); const locale = App.getPreferenceString("hl", App.defaultLangage);
if (window.i18n.global.locale.value !== locale) { if (window.i18n.global.locale.value !== locale) {
if (!window.i18n.global.availableLocales.includes(locale)) { if (!window.i18n.global.availableLocales.includes(locale)) {
const messages = await import("@/locales/" + locale + ".json").then(module => module.default); const messages = await import("@/locales/" + locale + ".json").then(module => module.default);

View File

@ -352,7 +352,7 @@ export default {
this.showComments = this.getPreferenceBoolean("comments", true); this.showComments = this.getPreferenceBoolean("comments", true);
this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false); this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false);
this.watchHistory = this.getPreferenceBoolean("watchHistory", false); this.watchHistory = this.getPreferenceBoolean("watchHistory", false);
this.selectedLanguage = this.getPreferenceString("hl", "en"); this.selectedLanguage = this.getPreferenceString("hl", this.defaultLangage);
this.enabledCodecs = this.getPreferenceString("enabledCodecs", "av1,vp9,avc").split(","); this.enabledCodecs = this.getPreferenceString("enabledCodecs", "av1,vp9,avc").split(",");
this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false); this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false);
this.proxyLBRY = this.getPreferenceBoolean("proxyLBRY", false); this.proxyLBRY = this.getPreferenceBoolean("proxyLBRY", false);
@ -377,7 +377,7 @@ export default {
if ( if (
this.getPreferenceString("theme", "dark") !== this.selectedTheme || this.getPreferenceString("theme", "dark") !== this.selectedTheme ||
this.getPreferenceBoolean("watchHistory", false) != this.watchHistory || this.getPreferenceBoolean("watchHistory", false) != this.watchHistory ||
this.getPreferenceString("hl", "en") !== this.selectedLanguage || this.getPreferenceString("hl", this.defaultLangage) !== this.selectedLanguage ||
this.getPreferenceString("enabledCodecs", "av1,vp9,avc") !== this.enabledCodecs.join(",") this.getPreferenceString("enabledCodecs", "av1,vp9,avc") !== this.enabledCodecs.join(",")
) )
shouldReload = true; shouldReload = true;

View File

@ -210,6 +210,18 @@ const mixin = {
return false; return false;
} }
}, },
defaultLangage() {
const languages = window.navigator.languages;
for (let i = 0; i < languages.length; i++) {
try {
require("@/locales/" + languages[i] + ".json");
return languages[i];
} catch {
continue;
}
}
return "en";
},
}, },
}; };