From 362b80311bd339eea5338ea220b62f745f29f774 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 10 Jan 2012 17:47:27 +0300 Subject: lang: add support for script command lg(). lang: fix creating empty files. lang: add new copyright to lang files. --- lang/updatelang.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lang/updatelang.py b/lang/updatelang.py index a0ccda4..5d49527 100755 --- a/lang/updatelang.py +++ b/lang/updatelang.py @@ -15,6 +15,7 @@ allStrings = set() strre1 = re.compile("[\t +(]l[(][\"](?P[^\"]+)[\"]") strre3 = re.compile("[\t +(]getitemlink[(][\"](?P[^\"]+)[\"][)]") strre2 = re.compile("^[^/](.+)[.]gat([^\t]+)[\t](script|shop)[\t](?P[\w ]+)[\t]([\d]+),") +strre4 = re.compile("[\t +(]lg[(][\"](?P[^\"]+)[\"]") itemsplit = re.compile(",") langFiles = dict() @@ -35,6 +36,10 @@ def collectStrings(parentDir): with open(file2, "r") as f: for line in f: m = strre1.findall(line) + if len(m) > 0: + for str in m: + allStrings.add(str) + m = strre4.findall(line) if len(m) > 0: for str in m: allStrings.add(str) @@ -81,6 +86,8 @@ def parseFile(name, readFirstLine): trans[line1] = line2 line1 = "" line2 = "" + elif readFirstLine: + firstLine = "Copyright (C) 2010-2012 Evol Online\n" return (trans, firstLine) @@ -193,7 +200,7 @@ def loadItemDb(dir): continue itemNamesByName[rows[1].lower().strip()] = rows[2].strip() -rootPath = "../../gittorious/serverdata" +rootPath = "../../gittorious/serverdata-beta" loadItemDb(rootPath + "/db") collectStrings(rootPath + "/npc") -- cgit v1.2.3-70-g09d2 From 315ce8f31fef26a5980456d5a2dd6c34f781fec7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 12 Jan 2012 00:53:13 +0300 Subject: lang: Fix for lg() parser. Now it write to lang file two strings with #0 and #1. --- lang/updatelang.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lang/updatelang.py b/lang/updatelang.py index 5d49527..9fd1459 100755 --- a/lang/updatelang.py +++ b/lang/updatelang.py @@ -42,7 +42,8 @@ def collectStrings(parentDir): m = strre4.findall(line) if len(m) > 0: for str in m: - allStrings.add(str) + allStrings.add(str + "#0") + allStrings.add(str + "#1") m = strre2.search(line) if m is not None: allStrings.add(m.group("str")) -- cgit v1.2.3-70-g09d2 From d63a5a0debaff0143a92bea6dfa0fb21e5a76aee Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 12 Jan 2012 00:54:30 +0300 Subject: Allow generate po english files without english translation. --- lang/converttopo.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lang/converttopo.py b/lang/converttopo.py index dc746bd..03c6c89 100755 --- a/lang/converttopo.py +++ b/lang/converttopo.py @@ -27,9 +27,12 @@ def loadFiles(dir): langs.add(line[:-1]) for file in langs: - langFiles[file] = parseFile(dir + "/lang_" + file + ".txt", True) + if file == "en": + langFiles[file] = parseFile(dir + "/lang_" + file + ".txt", True, True) + else: + langFiles[file] = parseFile(dir + "/lang_" + file + ".txt", True, False) -def parseFile(name, readFirstLine): +def parseFile(name, readFirstLine, isBaseLang): trans = dict() firstLine = None if os.path.exists(name): @@ -50,7 +53,10 @@ def parseFile(name, readFirstLine): continue line2 = line[:-1] - trans[line1] = line2 + if isBaseLang: + trans[line1] = line1 + else: + trans[line1] = line2 line1 = "" line2 = "" return (trans, firstLine) @@ -81,7 +87,7 @@ def saveFile(path, name): w.write ("msgstr \"" + line2 + "\"\n\n") -rootPath = "../../gittorious/serverdata" +rootPath = "../../gittorious/serverdata-beta" loadFiles(rootPath + "/langs") saveFiles("po") -- cgit v1.2.3-70-g09d2