From 467541cfad0b82e9b88d14bd69264ed537465d03 Mon Sep 17 00:00:00 2001 From: Angen Date: Sat, 5 Nov 2022 08:19:32 +0000 Subject: [PATCH] Do not break gui when fallback language is not available in termsdialog.js L10 falls back to language code, that means if "pt_x" is not available it falls back to "pt", but we do not provide "pt", same for "en" or after uninstalling and removing language pack and leaving language selected. Adding warning. Related post: https://wildfiregames.com/forum/topic/96800-terms-display-error This was SVN commit r27201. --- binaries/data/mods/mod/gui/termsdialog/termsdialog.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/binaries/data/mods/mod/gui/termsdialog/termsdialog.js b/binaries/data/mods/mod/gui/termsdialog/termsdialog.js index 4420e990bb..c47690c23f 100644 --- a/binaries/data/mods/mod/gui/termsdialog/termsdialog.js +++ b/binaries/data/mods/mod/gui/termsdialog/termsdialog.js @@ -62,8 +62,11 @@ function initLanguageSelection() // current locale let currentLocaleDict = Engine.GetFallbackToAvailableDictLocale(Engine.GetCurrentLocale()); - if (currentLocaleDict != baseNames[0]) - list.push(displayNames[baseNames.indexOf(currentLocaleDict)]); + let index = baseNames.indexOf(currentLocaleDict); + if (index == -1) + warn("Language '"+currentLocaleDict+"' is not available"); + else if (currentLocaleDict != baseNames[0]) + list.push(displayNames[index]); return list; })();