Fix loading of localization when browser returns region code

E.g. if the browser returns `de-DE` or `en-US` and we don't have those specific
ones, we want to fall back to `de` and `en` respectively.
This commit is contained in:
Jonas Herzig 2020-05-03 17:34:57 +02:00
parent d6d55c9f9c
commit 064dd195c1

View file

@ -31,7 +31,11 @@ var _data = {};
* @author svartoyg * @author svartoyg
*/ */
async function retrieveData (language) { async function retrieveData (language) {
try {
return (await import(`../loc/${language}.json`)).default return (await import(`../loc/${language}.json`)).default
} catch (exception) {
return (await import(`../loc/${language.substr(0, language.indexOf('-'))}.json`)).default
}
} }