Skip to content

Commit

Permalink
Update Base.js
Browse files Browse the repository at this point in the history
Related to #330.
  • Loading branch information
mclemente committed Oct 24, 2023
1 parent 994cbe5 commit 3a76342
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/module/providers/templates/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,21 +541,29 @@ export default class LanguageProvider {
* Otherwise, returns the system's default language.
*/
getDefaultLanguage() {
const defaultLang =
game.user.getFlag("polyglot", "defaultLanguage") ?? game.settings.get("polyglot", "defaultLanguage");
if (defaultLang) {
if (this.languages[defaultLang]) {
this.defaultLanguage = defaultLang;
const getLanguage = (language) => {
if (this.languages[language]) {
this.defaultLanguage = language;
} else {
Object.entries(this.languages).every(([key, lang]) => {
if (defaultLang === lang.label) {
if (language === lang.label) {
this.defaultLanguage = key;
return false;
}
return true;
});
}
} else {
};
const worldDefault = game.settings.get("polyglot", "defaultLanguage");
const userDefault = game.user.getFlag("polyglot", "defaultLanguage");
// We have to check for World's setting first because users might input an invalid language
if (worldDefault) {
getLanguage(worldDefault);
}
if (userDefault) {
getLanguage(userDefault);
}
if (this.defaultLanguage === undefined) {
this.defaultLanguage = this.getSystemDefaultLanguage();
}
}
Expand Down

0 comments on commit 3a76342

Please sign in to comment.