diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2023-11-07 08:17:01 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2023-11-07 08:18:33 -0400 |
commit | 4001e3c16c0acacc6c6d89589e57996701058dc0 (patch) | |
tree | 838461e2762922cd4ea723a2abed5ea5f277c148 /src | |
parent | a10e27f93c8e7965c51b2e0372a7f4b19640452e (diff) |
upd8: handle internal language updates in custom default language
Diffstat (limited to 'src')
-rwxr-xr-x | src/upd8.js | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/upd8.js b/src/upd8.js index 7d7e48b9..91f9a090 100755 --- a/src/upd8.js +++ b/src/upd8.js @@ -1259,19 +1259,12 @@ async function main() { logInfo`Applying new default strings from custom ${customDefaultLanguage.code} language file.`; - // The custom default language will be the new one providing fallback strings - // for other languages, but on its own, it still might not be a complete list - // of strings. So it falls back to the internal default language - which won't - // otherwise be presented on the site. - customDefaultLanguage.inheritedStrings = internalDefaultLanguage.strings; - finalDefaultLanguage = customDefaultLanguage; finalDefaultLanguageWatcher = customLanguageWatchers.find(({language}) => language === customDefaultLanguage); finalDefaultLanguageAnnotation = `using wiki-specified custom default language`; } else if (languages[internalDefaultLanguage.code]) { const customDefaultLanguage = languages[internalDefaultLanguage.code]; - customDefaultLanguage.inheritedStrings = internalDefaultLanguage.strings; finalDefaultLanguage = customDefaultLanguage; finalDefaultLanguageWatcher = customLanguageWatchers.find(({language}) => language === customDefaultLanguage); @@ -1284,6 +1277,12 @@ async function main() { finalDefaultLanguageAnnotation = `no custom default language specified`; } + const inheritStringsFromInternalLanguage = () => { + if (finalDefaultLanguage === internalDefaultLanguage) return; + const {strings: inheritedStrings} = internalDefaultLanguage; + Object.assign(finalDefaultLanguage, {inheritedStrings}); + }; + const inheritStringsFromDefaultLanguage = () => { const {strings: inheritedStrings} = finalDefaultLanguage; for (const language of Object.values(languages)) { @@ -1292,8 +1291,19 @@ async function main() { } }; - inheritStringsFromDefaultLanguage(); + // The custom default language, if set, will be the new one providing fallback + // strings for other languages. But on its own, it still might not be a complete + // list of strings - so it falls back to the internal default language, which + // won't otherwise be presented in the build. + if (finalDefaultLanguage !== internalDefaultLanguage) { + inheritStringsFromInternalLanguage(); + internalDefaultLanguageWatcher.on('update', () => { + inheritStringsFromInternalLanguage(); + inheritStringsFromDefaultLanguage(); + }); + } + inheritStringsFromDefaultLanguage(); finalDefaultLanguageWatcher.on('update', () => { inheritStringsFromDefaultLanguage(); }); |