Update translations.js

fixed `mapLanguageCodeToId` to correctly choose region
pull/1480/head
FelisNivalis 2 years ago committed by GitHub
parent c77e428ffb
commit 52ce856370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -32,7 +32,10 @@ function mapLanguageCodeToId(languageKey) {
// Try to match by key or short key
for (const id in LANGUAGES) {
const data = LANGUAGES[id];
const code = data.code.toLowerCase();
const shortCode = data.code.toLowerCase();
const region = data.region.toLowerCase();
const code = shortCode + (region ? "-" + region : "");
if (code === key) {
console.log("-> Match", languageKey, "->", id);
return id;
@ -46,8 +49,7 @@ function mapLanguageCodeToId(languageKey) {
// If none found, try to find a better alternative by using the base language at least
for (const id in LANGUAGES) {
const data = LANGUAGES[id];
const code = data.code.toLowerCase();
const shortCode = code.split("-")[0];
const shortCode = data.code.toLowerCase();
if (shortCode === key) {
console.log("-> Desperate Match", languageKey, "->", id);

Loading…
Cancel
Save