Skip to content

Commit 8894fec

Browse files
committed
Add localized string collector script.
1 parent 5ec6840 commit 8894fec

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tools/collect_localized_strings.py

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import os
2+
import sys
3+
import re
4+
5+
from lib import utils as Utils
6+
7+
def Main (argv):
8+
toolsDir = os.path.dirname (os.path.abspath (__file__))
9+
rootDir = os.path.dirname (toolsDir)
10+
os.chdir (rootDir)
11+
12+
sourceDirs = [
13+
os.path.join (rootDir, 'source'),
14+
os.path.join (rootDir, 'plugins'),
15+
]
16+
17+
relevantFiles = []
18+
for sourceDir in sourceDirs:
19+
for root, subdirs, files in os.walk (sourceDir):
20+
for file in files:
21+
if os.path.splitext (file)[1] == '.js':
22+
relevantFiles.append (os.path.join (root, file))
23+
24+
strings = []
25+
for file in relevantFiles:
26+
fileContent = Utils.GetFileContent (file)
27+
locMatches = re.findall ('[^F]Loc\s{0,1}\(\'(.*?)\'\)', fileContent)
28+
flocMatches = re.findall ('FLoc\s{0,1}\(\'(.*?)\'\,', fileContent)
29+
for matches in [locMatches, flocMatches]:
30+
for match in matches:
31+
if not match in strings:
32+
strings.append (match.replace ('\\\'', '\''))
33+
34+
strings.sort ()
35+
for string in strings:
36+
print (string)
37+
38+
return 0
39+
40+
sys.exit (Main (sys.argv))

0 commit comments

Comments
 (0)