summaryrefslogtreecommitdiff
path: root/lang/updatelang.py
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-09 22:17:26 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-09 22:17:26 +0300
commita62d4969b0d4958d6755dece550143c2cb746b56 (patch)
treec2a4dea9abfb2aabe1ca5ec3f896d6254d311c86 /lang/updatelang.py
parent26a08294551f5a882387ae5f25fd1c8ebb9a883f (diff)
downloadevol-tools-a62d4969b0d4958d6755dece550143c2cb746b56.tar.gz
evol-tools-a62d4969b0d4958d6755dece550143c2cb746b56.tar.bz2
evol-tools-a62d4969b0d4958d6755dece550143c2cb746b56.tar.xz
evol-tools-a62d4969b0d4958d6755dece550143c2cb746b56.zip
lang: search for translation strings in item_db.conf
Diffstat (limited to 'lang/updatelang.py')
-rwxr-xr-xlang/updatelang.py79
1 files changed, 42 insertions, 37 deletions
diff --git a/lang/updatelang.py b/lang/updatelang.py
index 397cfcb..2897367 100755
--- a/lang/updatelang.py
+++ b/lang/updatelang.py
@@ -39,8 +39,47 @@ def addStr(text, comment, fileName, lineNum, addNoC):
if addNoC == True:
strComments[text].add("#, no-c-format\n")
-def collectScriptStrings(parentDir, relativeDir):
+def collectScriptFileStrings(codeFile, file2):
global itemNamesByName
+ with open(file2, "r") as f:
+ cnt = -1
+ for line in f:
+ cnt = cnt + 1
+ line = line.replace("\\\"", "\a");
+ m = strre1.findall(line)
+ if len(m) > 0:
+ for str in m:
+ addStr(str, line, codeFile, cnt, True)
+ m = strre4.findall(line)
+ if len(m) > 0:
+ for str in m:
+ addStr(str + "#0", line, codeFile, cnt, True)
+ addStr(str + "#1", line, codeFile, cnt, True)
+ m = strre2.search(line)
+ if m is not None and m.group("str")[0] != "#":
+ addStr(m.group("str"), line, codeFile, cnt, True)
+ m = strre3.findall(line)
+ if len(m) > 0:
+ for str in m:
+ if str.lower() in itemNamesByName:
+ addStr(itemNamesByName[str.lower()], line, codeFile, cnt, True)
+ m = strre5.findall(line)
+ if len(m) > 0:
+ for str in m:
+ if str.lower() in itemNamesByName:
+ addStr(itemNamesByName[str.lower()], line, codeFile, cnt, True)
+ m = strre6.findall(line)
+ if len(m) > 0:
+ for str in m:
+ addStr(str, line, codeFile, cnt, True)
+ m = strre7.findall(line)
+ if len(m) > 0:
+ for str in m:
+ addStr(str[0] + "#0", line, codeFile, cnt, True)
+ addStr(str[2] + "#1", line, codeFile, cnt, True)
+
+
+def collectScriptStrings(parentDir, relativeDir):
files = os.listdir(parentDir)
for file1 in files:
if file1[0] == ".":
@@ -51,42 +90,7 @@ def collectScriptStrings(parentDir, relativeDir):
collectScriptStrings(file2, relativeDir2)
elif filt.search(file1):
codeFile = relativeDir + os.path.sep + file1
- with open(file2, "r") as f:
- cnt = -1
- for line in f:
- cnt = cnt + 1
- line = line.replace("\\\"", "\a");
- m = strre1.findall(line)
- if len(m) > 0:
- for str in m:
- addStr(str, line, codeFile, cnt, True)
- m = strre4.findall(line)
- if len(m) > 0:
- for str in m:
- addStr(str + "#0", line, codeFile, cnt, True)
- addStr(str + "#1", line, codeFile, cnt, True)
- m = strre2.search(line)
- if m is not None and m.group("str")[0] != "#":
- addStr(m.group("str"), line, codeFile, cnt, True)
- m = strre3.findall(line)
- if len(m) > 0:
- for str in m:
- if str.lower() in itemNamesByName:
- addStr(itemNamesByName[str.lower()], line, codeFile, cnt, True)
- m = strre5.findall(line)
- if len(m) > 0:
- for str in m:
- if str.lower() in itemNamesByName:
- addStr(itemNamesByName[str.lower()], line, codeFile, cnt, True)
- m = strre6.findall(line)
- if len(m) > 0:
- for str in m:
- addStr(str, line, codeFile, cnt, True)
- m = strre7.findall(line)
- if len(m) > 0:
- for str in m:
- addStr(str[0] + "#0", line, codeFile, cnt, True)
- addStr(str[2] + "#1", line, codeFile, cnt, True)
+ collectScriptFileStrings(codeFile, file2)
def collectMessages(messagesDir):
@@ -377,6 +381,7 @@ rootPath = "../../server-data/"
loadItemDb(rootPath + "db/re")
loadMobNames(rootPath + "db/re")
collectScriptStrings(rootPath + "/npc", "npc")
+collectScriptFileStrings("db/re/item_db.conf", rootPath + "/db/re/item_db.conf")
collectMessages(rootPath + "/conf/messages.conf")
loadFiles(rootPath + "/langs")
addMissingLines()