This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ploc.js
103 lines (91 loc) · 1.56 KB
/
ploc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/* eslint-disable @typescript-eslint/naming-convention */
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require("fs");
const yaml = require("yaml");
const pseudolocalizationMap = {
a: "á",
b: "β",
c: "ç",
d: "δ",
e: "è",
f: "ƒ",
g: "ϱ",
h: "λ",
i: "ï",
j: "J",
k: "ƙ",
l: "ℓ",
m: "₥",
n: "ñ",
o: "ô",
p: "ƥ",
q: "9",
r: "ř",
s: "ƨ",
t: "ƭ",
u: "ú",
v: "Ʋ",
w: "ω",
x: "ж",
y: "¥",
z: "ƺ",
A: "Â",
B: "ß",
C: "Ç",
D: "Ð",
E: "É",
F: "F",
G: "G",
H: "H",
I: "Ì",
J: "J",
K: "K",
L: "£",
M: "M",
N: "N",
O: "Ó",
P: "Þ",
Q: "Q",
R: "R",
S: "§",
T: "T",
U: "Û",
V: "V",
W: "W",
X: "X",
Y: "Ý",
Z: "Z",
};
const localizationsPath = "./public/strings";
const enUsContent = fs.readFileSync(`${localizationsPath}/en-us.yml`, "utf8");
const localizations = yaml.parse(enUsContent);
const pseudolocalizeString = string => {
let newString = "";
let blockPloc = false;
for (const c of string) {
if (c === "{") {
blockPloc = true;
}
if (blockPloc && c === "}") {
blockPloc = false;
}
if (!blockPloc && c in pseudolocalizationMap) {
newString += pseudolocalizationMap[c];
} else {
newString += c;
}
}
return newString;
};
const pseudolocalize = node => {
for (const key in node) {
if (typeof(node[key]) === "object") {
pseudolocalize(node[key]);
} else {
const line = node[key];
node[key] = pseudolocalizeString(line);
}
}
};
pseudolocalize(localizations);
fs.writeFileSync(`${localizationsPath}/ploc.yml`, yaml.stringify(localizations));