diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-03-06 17:51:07 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-03-06 19:29:55 +0300 |
commit | 5338c794caf4a3041c3da4a70ee1870a79a6d128 (patch) | |
tree | b79ae5425eabc90b916b0d3e99d2a8e96a508083 /lang | |
parent | c41ce0481e85a8095c5ce49a313bca0e9fb55e72 (diff) | |
download | evol-tools-5338c794caf4a3041c3da4a70ee1870a79a6d128.tar.gz evol-tools-5338c794caf4a3041c3da4a70ee1870a79a6d128.tar.bz2 evol-tools-5338c794caf4a3041c3da4a70ee1870a79a6d128.tar.xz evol-tools-5338c794caf4a3041c3da4a70ee1870a79a6d128.zip |
lang: save po comments in correct order
Diffstat (limited to 'lang')
-rwxr-xr-x | lang/updatelang.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/lang/updatelang.py b/lang/updatelang.py index 0da0172..d89032e 100755 --- a/lang/updatelang.py +++ b/lang/updatelang.py @@ -30,11 +30,12 @@ def addStr(text, comment, fileName, lineNum): allStrings.add(text) if comment[-1:] == "\n": comment = comment[:-1] - newComment = "#. code: " + comment.strip() + "\n#: " + fileName + ":" + str(lineNum) + "\n#, no-c-format\n" - if text in strComments: - strComments[text] = strComments[text] + newComment - else: - strComments[text] = newComment + if text not in strComments: + strComments[text] = set() + + strComments[text].add("#. code: " + comment.strip() + "\n") + strComments[text].add("#: " + fileName + ":" + str(lineNum) + "\n") + strComments[text].add("#, no-c-format\n") def collectStrings(parentDir, relativeDir): global itemNamesByName @@ -236,6 +237,19 @@ def writeLangFile(langDir, texts, trans, isold): trLine = trLine[:-2] f.write (trLine + "\n\n") +def writePoComments(w, comments): + for line in comments: + if line[:3] == "#. ": + w.write (line) + for line in comments: + if line[:3] == "#: ": + w.write (line) + + for line in comments: + if line[:3] == "#, ": + w.write (line) + break + def writePoFile(poDir, texts, trans): if trans == "en": langDir = poDir + "/" + trans + ".pot" @@ -255,7 +269,7 @@ def writePoFile(poDir, texts, trans): w.write ("\n") for line in texts[0]: if line[0] in strComments.keys(): - w.write (strComments[line[0]]) + writePoComments(w, strComments[line[0]]) w.write ("msgid \"" + line[0].replace("\"", "\\\"") + "\"\n") trLine = line[1] |