summaryrefslogtreecommitdiff
path: root/lang
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-17 02:10:10 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-17 02:16:45 +0200
commit3702e902426dc5add4199abe577c4195365f7a4f (patch)
treeeb7953fe90e746ac35144bd92465d2bd4d3f84cc /lang
parent8d8ff5ec76e8b38aecdc295765215c37d1c4acd7 (diff)
downloadevol-tools-3702e902426dc5add4199abe577c4195365f7a4f.tar.gz
evol-tools-3702e902426dc5add4199abe577c4195365f7a4f.tar.bz2
evol-tools-3702e902426dc5add4199abe577c4195365f7a4f.tar.xz
evol-tools-3702e902426dc5add4199abe577c4195365f7a4f.zip
lang: add support for extracting strings from getitemlink function.
Diffstat (limited to 'lang')
-rwxr-xr-xlang/updatelang.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/lang/updatelang.py b/lang/updatelang.py
index 3cd9a7c..2f16c3e 100755
--- a/lang/updatelang.py
+++ b/lang/updatelang.py
@@ -12,14 +12,17 @@ filt = re.compile(".+[.]txt", re.IGNORECASE)
allStrings = set()
strre1 = re.compile("[\t +(]l[(][\"](?P<str>[^\"]+)[\"]")
-#strre3 = re.compile("[\t +(]getitemlink[(][\"](?P<str>[^\"]+)[\"][)]")
+strre3 = re.compile("[\t +(]getitemlink[(][\"](?P<str>[^\"]+)[\"][)]")
strre2 = re.compile("^[^/](.+)[.]gat([^\t]+)[\t](script|shop)[\t](?P<str>[\w ]+)[\t]([\d]+),")
+itemsplit = re.compile(",")
langFiles = dict()
oldLangFiles = dict()
langs = set()
+itemNamesByName = dict()
def collectStrings(parentDir):
+ global itemNamesByName
files = os.listdir(parentDir)
for file1 in files:
if file1[0] == ".":
@@ -37,7 +40,11 @@ def collectStrings(parentDir):
m = strre2.search(line)
if m is not None:
allStrings.add(m.group("str"))
-
+ m = strre3.findall(line)
+ if len(m) > 0:
+ for str in m:
+ allStrings.add(itemNamesByName[str.lower()])
+
def loadFiles(dir):
with open(dir + "/langs.txt", "r") as f:
@@ -125,8 +132,18 @@ def writeFile(dir, texts):
f.write (line[1] + "\n\n")
+def loadItemDb(dir):
+ global itemNamesByName
+ with open(dir + "/item_db.txt", "r") as f:
+ for line in f:
+ rows = itemsplit.split(line)
+ if len(rows) < 5:
+ continue
+ itemNamesByName[rows[1].lower().strip()] = rows[2].strip()
+
+
+loadItemDb("../../privserverdata/db")
collectStrings("../../privserverdata/npc")
-#here need collect names from item_db.txt
loadFiles("../../privserverdata/langs")
addMissingLines()
sorting()