1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00

Update translations.js

fixed `mapLanguageCodeToId` to correctly choose region
This commit is contained in:
FelisNivalis 2022-09-27 22:39:24 +02:00 committed by GitHub
parent c77e428ffb
commit 52ce856370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);