Extracted strings and fixes on localization support
Language chooser in the UI
This commit is contained in:
parent
9f449c0a2f
commit
dc7789c17b
126 changed files with 2919 additions and 2028 deletions
66
shared/langs.js
Normal file
66
shared/langs.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
'use strict';
|
||||
|
||||
function convertToFake(dict) {
|
||||
function convertValueToFakeLang(str) {
|
||||
let from = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()-_=+\\|`~[{]};:'\",<.>/?";
|
||||
let to = "ɐqɔpǝɟƃɥıɾʞʅɯuodbɹsʇnʌʍxʎz∀ԐↃᗡƎℲ⅁HIſӼ⅂WNOԀÒᴚS⊥∩ɅMX⅄Z0123456789¡@#$%ᵥ⅋⁎()-_=+\\|,~[{]};:,„´<.>/¿";
|
||||
|
||||
return str.replace(/(\{\{[^\}]+\}\}|%s)/g, '\x00\x04$1\x00').split('\x00').map(c => {
|
||||
if (c.charAt(0) === '\x04') {
|
||||
return c;
|
||||
}
|
||||
let r = '';
|
||||
for (let i = 0, len = c.length; i < len; i++) {
|
||||
let pos = from.indexOf(c.charAt(i));
|
||||
if (pos < 0) {
|
||||
r += c.charAt(i);
|
||||
} else {
|
||||
r += to.charAt(pos);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}).join('\x00').replace(/[\x00\x04]/g, '');
|
||||
}
|
||||
|
||||
function _convertToFake(dict, fakeDict) {
|
||||
for (const key in dict) {
|
||||
const val = dict[key];
|
||||
|
||||
if (typeof val === 'string') {
|
||||
fakeDict[key] = convertValueToFakeLang(val);
|
||||
} else {
|
||||
fakeDict[key] = _convertToFake(val, {});
|
||||
}
|
||||
}
|
||||
|
||||
return fakeDict;
|
||||
}
|
||||
|
||||
return _convertToFake(dict, {});
|
||||
}
|
||||
|
||||
const langCodes = {
|
||||
en_US: {
|
||||
getShortLabel: t => t('EN'),
|
||||
getLabel: t => t('English'),
|
||||
shortCode: 'en',
|
||||
longCode: 'en_US'
|
||||
},
|
||||
es: {
|
||||
getShortLabel: t => t('ES'),
|
||||
getLabel: t => t('Spanish'),
|
||||
shortCode: 'es',
|
||||
longCode: 'es'
|
||||
},
|
||||
fake: {
|
||||
getShortLabel: t => t('FAKE'),
|
||||
getLabel: t => t('Fake'),
|
||||
shortCode: 'fake',
|
||||
longCode: 'fake'
|
||||
}
|
||||
}
|
||||
|
||||
langCodes.en = langCodes.en_US;
|
||||
|
||||
module.exports.convertToFake = convertToFake;
|
||||
module.exports.langCodes = langCodes;
|
|
@ -15,16 +15,16 @@ function passwordValidator(t) {
|
|||
if (t) {
|
||||
config.translate = {
|
||||
minLength: function (minLength) {
|
||||
return t('The password must be at least {{ minLength }} characters long', { minLength });
|
||||
return t('thePasswordMustBeAtLeastMinLength', { minLength });
|
||||
},
|
||||
maxLength: function (maxLength) {
|
||||
return t('The password must be fewer than {{ maxLength }} characters', { maxLength });
|
||||
return t('thePasswordMustBeFewerThanMaxLength', { maxLength });
|
||||
},
|
||||
repeat: t('The password may not contain sequences of three or more repeated characters'),
|
||||
lowercase: t('The password must contain at least one lowercase letter'),
|
||||
uppercase: t('The password must contain at least one uppercase letter'),
|
||||
number: t('The password must contain at least one number'),
|
||||
special: t('The password must contain at least one special character')
|
||||
repeat: t('thePasswordMayNotContainSequencesOfThree'),
|
||||
lowercase: t('thePasswordMustContainAtLeastOne'),
|
||||
uppercase: t('thePasswordMustContainAtLeastOne-1'),
|
||||
number: t('thePasswordMustContainAtLeastOneNumber'),
|
||||
special: t('thePasswordMustContainAtLeastOneSpecial')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue