Line endings fixed so that we don't have CRLF in Git. Better now than later.
This commit is contained in:
parent
2fe7f82be3
commit
d482d214d9
69 changed files with 6405 additions and 6405 deletions
130
shared/langs.js
130
shared/langs.js
|
@ -1,66 +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, {});
|
||||
}
|
||||
|
||||
// The langugage labels below are intentionally not localized so that they are always native in the langugae of their speaker (regardless of the currently selected language)
|
||||
const langCodes = {
|
||||
'en-US': {
|
||||
getShortLabel: t => 'EN',
|
||||
getLabel: t => 'English',
|
||||
longCode: 'en-US'
|
||||
},
|
||||
'es-ES': {
|
||||
getShortLabel: t => 'ES',
|
||||
getLabel: t => 'Español',
|
||||
longCode: 'es-ES'
|
||||
},
|
||||
'fk-FK': {
|
||||
getShortLabel: t => 'FK',
|
||||
getLabel: t => 'Fake',
|
||||
longCode: 'fk-FK'
|
||||
}
|
||||
}
|
||||
|
||||
function getLang(lng) {
|
||||
return langCodes[lng];
|
||||
}
|
||||
|
||||
module.exports.convertToFake = convertToFake;
|
||||
'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, {});
|
||||
}
|
||||
|
||||
// The langugage labels below are intentionally not localized so that they are always native in the langugae of their speaker (regardless of the currently selected language)
|
||||
const langCodes = {
|
||||
'en-US': {
|
||||
getShortLabel: t => 'EN',
|
||||
getLabel: t => 'English',
|
||||
longCode: 'en-US'
|
||||
},
|
||||
'es-ES': {
|
||||
getShortLabel: t => 'ES',
|
||||
getLabel: t => 'Español',
|
||||
longCode: 'es-ES'
|
||||
},
|
||||
'fk-FK': {
|
||||
getShortLabel: t => 'FK',
|
||||
getLabel: t => 'Fake',
|
||||
longCode: 'fk-FK'
|
||||
}
|
||||
}
|
||||
|
||||
function getLang(lng) {
|
||||
return langCodes[lng];
|
||||
}
|
||||
|
||||
module.exports.convertToFake = convertToFake;
|
||||
module.exports.getLang = getLang;
|
Loading…
Add table
Add a link
Reference in a new issue