Telegram Web K with changes to work inside I2P
https://web.telegram.i2p/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
835 B
38 lines
835 B
![]()
3 years ago
|
const fs = require('fs');
|
||
|
|
||
|
let str = fs.readFileSync('../lang.ts').toString().replace(/\s.+\/\/.+/g, '');
|
||
|
{
|
||
|
const pattern = '= {';
|
||
|
str = str.slice(str.indexOf(pattern) + pattern.length - 1);
|
||
|
}
|
||
|
|
||
|
{
|
||
|
const pattern = '};';
|
||
|
str = str.slice(0, str.indexOf(pattern) + pattern.length - 1);
|
||
|
}
|
||
|
|
||
|
//console.log(str);
|
||
|
const json = JSON.parse(str);
|
||
|
//console.log(json);
|
||
|
|
||
|
const f = (key, value, plural) => {
|
||
|
value = value
|
||
|
.replace(/\n/g, '\\n')
|
||
|
.replace(/"/g, '\\"');
|
||
|
return `"${key}${plural ? '_' + plural.replace('_value', '') : ''}" = "${value}";\n`;
|
||
|
};
|
||
|
|
||
|
let out = '';
|
||
|
for(const key in json) {
|
||
|
const value = json[key];
|
||
|
if(typeof(value) === 'string') {
|
||
|
out += f(key, value);
|
||
|
} else {
|
||
|
for(const plural in value) {
|
||
|
out += f(key, value[plural], plural);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fs.writeFileSync('./out/langPack.strings', out);
|