make frontend translation fallback to keys if missing

indiachan-spamvector
Thomas Lynch 2 years ago
parent c553a60936
commit 2aa5d1afbe
  1. 8
      gulp/res/js/i18n.js

@ -8,11 +8,15 @@ const pluralMap = {
//simple translation //simple translation
const __ = (key) => { const __ = (key) => {
return LANG[key]; return LANG[key] || key;
}; };
//plurals+replace %s with count //plurals+replace %s with count
const __n = (key, count) => { const __n = (key, count) => {
const pluralKey = pluralMap[count] || 'other'; const pluralKey = pluralMap[count] || 'other';
return LANG[key][pluralKey].replace('%s', count); const translationObj = LANG[key];
if (!translationObj) {
return key;
}
return translationObj[pluralKey].replace('%s', count);
}; };

Loading…
Cancel
Save