Skip to content

Commit 1eff63e

Browse files
Merge pull request #734 from onichama/loc_tools
Tools to help find missing entries in localization files
2 parents 59f9edb + 675c048 commit 1eff63e

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

localization/tools/find_missing.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""
2+
This Script searches for missing entries in a given localization lua-file,
3+
comparing its contents to en-us.lua.
4+
5+
Author: Avery (@onichama)
6+
"""
7+
8+
vars_en = []
9+
vars_other = []
10+
11+
def read_vars_from_file(filename, into_list):
12+
with open(filename) as file_en:
13+
for line in file_en:
14+
if " = {" in line and "text = {" not in line and "unlock = {" not in line:
15+
into_list.append(line.split(" = {")[0].strip())
16+
17+
read_vars_from_file("../en-us.lua", vars_en) # Take EN-US as base language
18+
read_vars_from_file("../de.lua", vars_other) # Change this to the language you want to compare to
19+
20+
for var in vars_en:
21+
if var not in vars_other:
22+
print(var)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
"""
2+
This Script searches for missing entries in a given localization lua-file,
3+
comparing its contents to en-us.lua.
4+
This version also gives the full "path" to a given entry, and can detect
5+
stuff like missing unlock descriptors.
6+
7+
Author: Avery (@onichama)
8+
"""
9+
10+
vars_en = []
11+
vars_other = []
12+
13+
def read_vars_from_file(filename, into_list):
14+
current_var_path = []
15+
with open(filename) as file_en:
16+
for line in file_en:
17+
if " = {" in line:
18+
current_var = line.split(" = {")[0].strip()
19+
current_var_path.append(current_var)
20+
into_list.append(".".join(current_var_path))
21+
if ("},\n" in line or "}\n" in line) and len(current_var_path) > 0:
22+
current_var_path.pop(len(current_var_path)-1)
23+
24+
read_vars_from_file("../en-us.lua", vars_en) # Take EN-US as base language
25+
read_vars_from_file("../de.lua", vars_other) # Change this to the language you want to compare to
26+
27+
for var in vars_en:
28+
if var not in vars_other:
29+
print(var)

0 commit comments

Comments
 (0)