From 064dd195c1246ccb7948fe148fb951430c360e5e Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Sun, 3 May 2020 17:34:57 +0200 Subject: [PATCH] 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. --- app/loc.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/loc.js b/app/loc.js index a483154..5425688 100644 --- a/app/loc.js +++ b/app/loc.js @@ -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 + } }