Skip to content

Commit

Permalink
Update dsa5.js
Browse files Browse the repository at this point in the history
  • Loading branch information
mclemente committed Sep 7, 2024
1 parent 20f39e7 commit f8588ce
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/module/providers/dsa5.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,24 +276,23 @@ export default class dsa5LanguageProvider extends LanguageProvider {
const languageRegex = new RegExp(`${game.i18n.localize("LocalizedIDs.language")}\\s*\\((.+)\\)`, "i");
const literacyRegex = new RegExp(`${game.i18n.localize("LocalizedIDs.literacy")}\\s*\\((.+)\\)`, "i");
const languagesSetting = game.settings.get("polyglot", "Languages");
for (const item of dsa5ItemList) {
if (languageRegex.test(item.name)) {
const label = item.name.match(languageRegex)[1].trim();
const key = label.toLowerCase();
languages[key] = {
label,
font: languagesSetting[key]?.font || this.languages[key]?.font || this.defaultFont,
rng: languagesSetting[key]?.rng ?? "default",
};
} else if (literacyRegex.test(item.name)) {
const label = item.name.match(literacyRegex)[1].trim();

const setLanguageInfo = (item, regex) => {
const match = item.name.match(regex);
if (match) {
const label = match[1].trim();
const key = label.toLowerCase();
languages[key] = {
label,
font: languagesSetting[key]?.font || this.languages[key]?.font || this.defaultFont,
rng: languagesSetting[key]?.rng ?? "default",
};
}
};

for (const item of dsa5ItemList) {
if (languageRegex.test(item.name)) setLanguageInfo(item, languageRegex);
else if (literacyRegex.test(item.name)) setLanguageInfo(item, literacyRegex);
}
this.languages = languages;
} else {
Expand Down

0 comments on commit f8588ce

Please sign in to comment.