Mercurial > hg-stable
comparison i18n/check-translation.py @ 20514:410c80539c5c
i18n: check equality of tail '::'-ness between msgid and msgstr
Document generation by runrst in "doc" directory may succeed silently,
even though there is the translated message missing tail '::'. In this
case, it uses "<blockquote>" instead of "<pre>" to surround succeeding
text block unexpectedly in generated HTML file.
This patch adds the checker to check equality of tail '::'-ness
between msgid and msgstr.
To detect also msgstr unexpectedly ending with '::', this checker
doesn't have matching regexp against msgid, and is applied on all
msgid/msgstr pairs.
This checker is categorized as "warning" level, because problem
detected by this is not so serious for usual Mercurial usage.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 15 Feb 2014 18:40:39 +0900 |
parents | 1ddf4409229f |
children | 6afbfb9b1af1 |
comparison
equal
deleted
inserted
replaced
20513:dcd3bebf4786 | 20514:410c80539c5c |
---|---|
63 | 63 |
64 #################### | 64 #################### |
65 | 65 |
66 def warningchecker(msgidpat=None): | 66 def warningchecker(msgidpat=None): |
67 return checker('warning', msgidpat) | 67 return checker('warning', msgidpat) |
68 | |
69 @warningchecker() | |
70 def taildoublecolons(pe): | |
71 """Check equality of tail '::'-ness between msgid and msgstr | |
72 | |
73 >>> pe = polib.POEntry( | |
74 ... msgid ='ends with ::', | |
75 ... msgstr='ends with ::') | |
76 >>> for e in taildoublecolons(pe): print e | |
77 >>> pe = polib.POEntry( | |
78 ... msgid ='ends with ::', | |
79 ... msgstr='ends without double-colons') | |
80 >>> for e in taildoublecolons(pe): print e | |
81 tail '::'-ness differs between msgid and msgstr | |
82 >>> pe = polib.POEntry( | |
83 ... msgid ='ends without double-colons', | |
84 ... msgstr='ends with ::') | |
85 >>> for e in taildoublecolons(pe): print e | |
86 tail '::'-ness differs between msgid and msgstr | |
87 """ | |
88 if pe.msgid.endswith('::') != pe.msgstr.endswith('::'): | |
89 yield "tail '::'-ness differs between msgid and msgstr" | |
68 | 90 |
69 #################### | 91 #################### |
70 | 92 |
71 def check(pofile, fatal=True, warning=False): | 93 def check(pofile, fatal=True, warning=False): |
72 targetlevel = { 'fatal': fatal, 'warning': warning } | 94 targetlevel = { 'fatal': fatal, 'warning': warning } |