Skip to content

Commit

Permalink
Maybe fix browsercheck escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper committed Dec 3, 2024
1 parent ed034db commit 72dfb39
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/build-browsercheck-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ import zhCHT from './locale/zhCHT.json' with { type: 'json' };
function getI18nKey(key) {
let key1 = key.split('.')[0];
let key2 = key.split('.')[1];
return ` en: "${en[key1][key2]}",
de: "${de[key1]?.[key2] ?? en[key1][key2]}",
es: "${es[key1]?.[key2] ?? en[key1][key2]}",
'es-mx': "${esMX[key1]?.[key2] ?? en[key1][key2]}",
fr: "${fr[key1]?.[key2] ?? en[key1][key2]}",
it: "${it[key1]?.[key2] ?? en[key1][key2]}",
ja: "${ja[key1]?.[key2] ?? en[key1][key2]}",
ko: "${ko[key1]?.[key2] ?? en[key1][key2]}",
pl: "${pl[key1]?.[key2] ?? en[key1][key2]}",
'pt-br': "${ptBR[key1]?.[key2] ?? en[key1][key2]}",
ru: "${ru[key1]?.[key2] ?? en[key1][key2]}",
'zh-chs': "${zhCHS[key1]?.[key2] ?? en[key1][key2]}",
'zh-cht': "${zhCHT[key1]?.[key2] ?? en[key1][key2]}",\n};`;
let getStringFor = (lang) => {
const str = lang[key1]?.[key2] ?? en[key1][key2];
return JSON.stringify(str);
};
return ` en: ${getStringFor(en)},
de: ${getStringFor(de)},
es: ${getStringFor(es)},
'es-mx': ${getStringFor(esMX)},
fr: ${getStringFor(fr)},
it: ${getStringFor(it)},
ja: ${getStringFor(ja)},
ko: ${getStringFor(ko)},
pl: ${getStringFor(pl)},
'pt-br': ${getStringFor(ptBR)},
ru: ${getStringFor(ru)},
'zh-chs': ${getStringFor(zhCHS)},
'zh-cht': ${getStringFor(zhCHT)},\n};`;
}

var browserCheckUtils = `export const supportedLanguages = [
Expand Down

0 comments on commit 72dfb39

Please sign in to comment.