diff --git a/system/scripts/actors/character-sheet.js b/system/scripts/actors/character-sheet.js index 582f047..3b55554 100644 --- a/system/scripts/actors/character-sheet.js +++ b/system/scripts/actors/character-sheet.js @@ -86,7 +86,7 @@ export class CharacterSheetL5r5e extends BaseCharacterSheetL5r5e { html, "system.identity.family", CONFIG.l5r5e.families.get( - Object.entries(game.i18n.translations.l5r5e.clans).find( + Object.entries(game.l5r5e.HelpersL5r5e.getLocalizedRawObject("l5r5e.clans")).find( ([k, v]) => v === this.actor.system.identity.clan )?.[0] ) diff --git a/system/scripts/actors/twenty-questions-dialog.js b/system/scripts/actors/twenty-questions-dialog.js index 2907b7f..a366b53 100644 --- a/system/scripts/actors/twenty-questions-dialog.js +++ b/system/scripts/actors/twenty-questions-dialog.js @@ -232,7 +232,7 @@ export class TwentyQuestionsDialog extends FormApplication { html, "step2.family", CONFIG.l5r5e.families.get( - Object.entries(game.i18n.translations.l5r5e.clans).find( + Object.entries(game.l5r5e.HelpersL5r5e.getLocalizedRawObject("l5r5e.clans")).find( ([k, v]) => v === this.object.data.step1.clan )?.[0] ) diff --git a/system/scripts/helpers.js b/system/scripts/helpers.js index a472f2d..0941ae9 100644 --- a/system/scripts/helpers.js +++ b/system/scripts/helpers.js @@ -84,7 +84,7 @@ export class HelpersL5r5e { * @return {string[]} */ static getLocalizedClansList() { - return Object.entries(game.i18n.translations.l5r5e.clans) + return Object.entries(game.l5r5e.HelpersL5r5e.getLocalizedRawObject("l5r5e.clans")) .filter(([k, v]) => !["title", "label"].includes(k)) .map(([k, v]) => v); } @@ -101,6 +101,20 @@ export class HelpersL5r5e { return Array.from(comp.index).map((v) => v.name); } + /** + * Get the raw object from localization, with fallback if the selected language is unknown + * @param {string} key + * @returns {*} + */ + static getLocalizedRawObject(key) { + let object = foundry.utils.getProperty(game.i18n.translations, key); + if (!!object) { + return object; + } + object = foundry.utils.getProperty(game.i18n._fallback, key); + return object ?? key; + } + /** * Return the list of Roles * @return {string[]}