-
Notifications
You must be signed in to change notification settings - Fork 87
/
create_en_ud.py
150 lines (135 loc) · 4.07 KB
/
create_en_ud.py
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
def replace_simple(replacement):
return lambda text, index: replacement
def replace_backslash(text, index):
if index + 1 < len(text):
next = text[index + 1]
if next == '"': # \"
return ",,"
elif next == "n": # \n
return "\\n"
print(f"Special handling fell back to the default case. Tried to replace \ at index {index}: '{text}'")
return "\\"
def replace_percent_sign(text, index):
if index + 1 < len(text):
next = text[index + 1]
if next == "s": # %s
return "%s"
elif next.isnumeric() and text[index + 2] == "$" and text[index + 3] == "s": # %1$s, %2$s, ...
return text[index:index + 4]
print(f"Special handling fell back to the default case. Tried to replace % at index {index}: '{text}'")
return "%"
replacements = {
"A": replace_simple("Ɐ"),
"B": replace_simple("ᗺ"),
"C": replace_simple("Ɔ"),
"D": replace_simple("ᗡ"),
"E": replace_simple("Ǝ"),
"F": replace_simple("Ⅎ"),
"G": replace_simple("⅁"),
"H": replace_simple("H"),
"I": replace_simple("I"),
"J": replace_simple("Ր"),
"K": replace_simple("Ʞ"),
"L": replace_simple("Ꞁ"),
"M": replace_simple("W"),
"N": replace_simple("N"),
"O": replace_simple("O"),
"P": replace_simple("Ԁ"),
"Q": replace_simple("Ꝺ"),
"R": replace_simple("ᴚ"),
"S": replace_simple("S"),
"T": replace_simple("⟘"),
"U": replace_simple("∩"),
"V": replace_simple("Ʌ"),
"W": replace_simple("M"),
"X": replace_simple("X"),
"Y": replace_simple("⅄"),
"Z": replace_simple("Z"),
"a": replace_simple("ɐ"),
"b": replace_simple("q"),
"c": replace_simple("ɔ"),
"d": replace_simple("p"),
"e": replace_simple("ǝ"),
"f": replace_simple("ɟ"),
"g": replace_simple("ᵷ"),
"h": replace_simple("ɥ"),
"i": replace_simple("ᴉ"),
"j": replace_simple("ɾ"),
"k": replace_simple("ʞ"),
"l": replace_simple("ꞁ"),
"m": replace_simple("ɯ"),
"n": replace_simple("u"),
"o": replace_simple("o"),
"p": replace_simple("d"),
"q": replace_simple("b"),
"r": replace_simple("ɹ"),
"s": replace_simple("s"),
"t": replace_simple("ʇ"),
"u": replace_simple("n"),
"v": replace_simple("ʌ"),
"w": replace_simple("ʍ"),
"x": replace_simple("x"),
"y": replace_simple("ʎ"),
"z": replace_simple("z"),
"0": replace_simple("0"),
"1": replace_simple("⥝"),
"2": replace_simple("ᘔ"),
"3": replace_simple("Ɛ"),
"4": replace_simple("߈"),
"5": replace_simple("ϛ"),
"6": replace_simple("9"),
"7": replace_simple("ㄥ"),
"8": replace_simple("8"),
"9": replace_simple("6"),
"'": replace_simple(","),
",": replace_simple("'"),
"=": replace_simple("="),
"+": replace_simple("+"),
"/": replace_simple("/"),
"*": replace_simple("*"),
"-": replace_simple("-"),
"(": replace_simple(")"),
")": replace_simple("("),
"[": replace_simple("]"),
"]": replace_simple("["),
"{": replace_simple("}"),
"}": replace_simple("{"),
".": replace_simple("˙"),
";": replace_simple("⸵"),
" ": replace_simple(" "),
"?": replace_simple("¿"),
"!": replace_simple("¡"),
"&": replace_simple("⅋"),
"_": replace_simple("‾"),
"^": replace_simple("^"),
"#": replace_simple("#"),
":": replace_simple(":"),
"<": replace_simple(">"),
">": replace_simple("<"),
"\\": replace_backslash,
"%": replace_percent_sign
}
with open("src/main/resources/assets/securitycraft/lang/en_us.json", encoding="UTF-8") as file:
lines = file.readlines()
upside_down_lines = []
max = len(lines) - 1
upside_down_lines.append("{\n")
for line_i in range(1, max):
split = lines[line_i].split('": "')
text_i = 0
# The last line needs to be special-cased, because it ends with " instead of ",
if split[1].endswith('",\n'):
text = split[1][:-3]
line = '",\n'
else:
text = split[1][:-2]
line = '"\n'
while text_i < len(text):
replacement = replacements[text[text_i]](text, text_i)
line = replacement + line
text_i += len(replacement)
upside_down_lines.append(f'{split[0]}": "{line}')
upside_down_lines.append("}")
with open("src/main/resources/assets/securitycraft/lang/en_ud.json", "w", encoding="UTF-8") as file:
for line in upside_down_lines:
file.write(line)