Patchwork [1,of,2,RESEND] i18n: check equality of tail '::'-ness between msgid and msgstr

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Feb. 15, 2014, 9:45 a.m.
Message ID <597376acecd24abf66f6.1392457502@juju>
Download mbox | patch
Permalink /patch/3666/
State Accepted
Commit 410c80539c5c2fdf41f5d451730c55c7641cb9ca
Headers show

Comments

Katsunori FUJIWARA - Feb. 15, 2014, 9:45 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1392457239 -32400
#      Sat Feb 15 18:40:39 2014 +0900
# Node ID 597376acecd24abf66f6bf1a245299fec90559a9
# Parent  7648e9aef6eeab00a0946e877690e94fb12d389b
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.

Patch

diff --git a/i18n/check-translation.py b/i18n/check-translation.py
--- a/i18n/check-translation.py
+++ b/i18n/check-translation.py
@@ -66,6 +66,28 @@ 
 def warningchecker(msgidpat=None):
     return checker('warning', msgidpat)
 
+@warningchecker()
+def taildoublecolons(pe):
+    """Check equality of tail '::'-ness between msgid and msgstr
+
+    >>> pe = polib.POEntry(
+    ...     msgid ='ends with ::',
+    ...     msgstr='ends with ::')
+    >>> for e in taildoublecolons(pe): print e
+    >>> pe = polib.POEntry(
+    ...     msgid ='ends with ::',
+    ...     msgstr='ends without double-colons')
+    >>> for e in taildoublecolons(pe): print e
+    tail '::'-ness differs between msgid and msgstr
+    >>> pe = polib.POEntry(
+    ...     msgid ='ends without double-colons',
+    ...     msgstr='ends with ::')
+    >>> for e in taildoublecolons(pe): print e
+    tail '::'-ness differs between msgid and msgstr
+    """
+    if pe.msgid.endswith('::') != pe.msgstr.endswith('::'):
+        yield "tail '::'-ness differs between msgid and msgstr"
+
 ####################
 
 def check(pofile, fatal=True, warning=False):