mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-05 09:42:33 +01:00
Improve the check_trans script by using Supybot's .po(t) parser.
The previous method matched line by line, which broke for msgmerge alternative (poedit\!\!\!) that changes line breaks.
This commit is contained in:
parent
12e652f7db
commit
3c695c4a15
@ -3,8 +3,11 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import glob
|
import glob
|
||||||
|
import operator
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
from supybot.i18n import parse
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
directory = sys.argv[1]
|
directory = sys.argv[1]
|
||||||
if directory == '--core':
|
if directory == '--core':
|
||||||
@ -63,27 +66,11 @@ def checkPlugin(pluginPath):
|
|||||||
|
|
||||||
def checkTranslation(pot, po):
|
def checkTranslation(pot, po):
|
||||||
checking = False
|
checking = False
|
||||||
for potLine in pot:
|
pot = set(map(operator.itemgetter(0), parse(pot)))
|
||||||
if not checking and potLine.startswith('msgid'):
|
po = set(map(operator.itemgetter(0), parse(po)))
|
||||||
checking = True
|
diff = filter(lambda x:x not in po, pot)
|
||||||
while True:
|
print(diff)
|
||||||
poLine = po.readline()
|
return not bool(diff)
|
||||||
if poLine == '': # EOF
|
|
||||||
return False
|
|
||||||
if poLine.startswith('msgid'):
|
|
||||||
if poLine == potLine:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
continue
|
|
||||||
elif checking and potLine.startswith('msgstr'):
|
|
||||||
checking = False
|
|
||||||
|
|
||||||
if checking:
|
|
||||||
poLine = po.readline()
|
|
||||||
if potLine != poLine:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user