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
*/
async function retrieveData (language) {
return (await import(`../loc/${language}.json`)).default
try {
return (await import(`../loc/${language}.json`)).default
} catch (exception) {
return (await import(`../loc/${language.substr(0, language.indexOf('-'))}.json`)).default
}
}