summaryrefslogtreecommitdiff
path: root/lang/updatelang.py
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-03-06 17:26:34 +0300
committerAndrei Karas <akaras@inbox.ru>2015-03-06 17:26:34 +0300
commit267c987d3a252b272fe7da7cc5e0a3d1e85dc667 (patch)
treee9379b724a6f92ce4761093dd2f7e05c78e96e7a /lang/updatelang.py
parent89b40f1d0c486c3693250183a07484bb17c10668 (diff)
downloadevol-tools-267c987d3a252b272fe7da7cc5e0a3d1e85dc667.tar.gz
evol-tools-267c987d3a252b272fe7da7cc5e0a3d1e85dc667.tar.bz2
evol-tools-267c987d3a252b272fe7da7cc5e0a3d1e85dc667.tar.xz
evol-tools-267c987d3a252b272fe7da7cc5e0a3d1e85dc667.zip
lang: save text code line into each po line.
Diffstat (limited to 'lang/updatelang.py')
-rwxr-xr-xlang/updatelang.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/lang/updatelang.py b/lang/updatelang.py
index b8ac62f..eab325d 100755
--- a/lang/updatelang.py
+++ b/lang/updatelang.py
@@ -11,6 +11,7 @@ defaultLang = "en"
filt = re.compile(".+[.]txt", re.IGNORECASE)
allStrings = set()
+strComments = dict()
strre1 = re.compile("[\t +(]l[(][\"](?P<str>[^\"]+)[\"]")
strre3 = re.compile("[\t +(]getitemlink[(][\"](?P<str>[^\"]+)[\"][)]")
strre2 = re.compile("^[^/](.+)([^\t]+)[\t](script|shop)[\t](?P<str>[^\t]+)[\t]([\d]+),")
@@ -25,6 +26,12 @@ oldLangFiles = dict()
langs = set()
itemNamesByName = dict()
+def addStr(str, comment):
+ allStrings.add(str)
+ if comment[-1:] == "\n":
+ comment = comment[:-1]
+ strComments[str] = comment.strip() + "\n"
+
def collectStrings(parentDir):
global itemNamesByName
files = os.listdir(parentDir)
@@ -40,35 +47,34 @@ def collectStrings(parentDir):
m = strre1.findall(line)
if len(m) > 0:
for str in m:
- allStrings.add(str)
+ addStr(str, line)
m = strre4.findall(line)
if len(m) > 0:
for str in m:
- allStrings.add(str + "#0")
- allStrings.add(str + "#1")
+ addStr(str + "#0", line)
+ addStr(str + "#1", line)
m = strre2.search(line)
if m is not None and m.group("str")[0] != "#":
- allStrings.add(m.group("str"))
+ addStr(m.group("str"), line)
m = strre3.findall(line)
if len(m) > 0:
for str in m:
if str.lower() in itemNamesByName:
- allStrings.add(itemNamesByName[str.lower()])
+ addStr(itemNamesByName[str.lower()], line)
m = strre5.findall(line)
if len(m) > 0:
for str in m:
if str.lower() in itemNamesByName:
- allStrings.add(itemNamesByName[str.lower()])
+ addStr(itemNamesByName[str.lower()], line)
m = strre6.findall(line)
if len(m) > 0:
for str in m:
- allStrings.add(str)
+ addStr(str, line)
m = strre7.findall(line)
if len(m) > 0:
for str in m:
- allStrings.add(str[0] + "#0")
- allStrings.add(str[2] + "#1")
-
+ addStr(str[0] + "#0", line)
+ addStr(str[2] + "#1", line)
@@ -240,6 +246,9 @@ def writePoFile(poDir, texts, trans):
w.write ("\"Content-Transfer-Encoding: 8bit\\n\"\n")
w.write ("\n")
for line in texts[0]:
+ if line[0] in strComments.keys():
+ w.write ("#. code: " + strComments[line[0]])
+
w.write ("msgid \"" + line[0].replace("\"", "\\\"") + "\"\n")
trLine = line[1]
if trans == "en":