Commits

Katsunori FUJIWARA committed 0f85440

tools: enhance check around translation for "ui.promptchoice()"

Comments (0)

Files changed (2)

         elif colwidth(msgstrs[0]) != colwidth(msgstrs[1]):
             msgs.append("length of title mark line isn't equal to title")
 
+    if '$$' in infostock[0]:
+        idparts = infostock[0].split('$$')
+        idmsg = idparts[0].rstrip(' ').decode('string-escape')
+        idresps = [(s.find('&'), len(s)) for s in
+                   [p.strip(' ') for p in idparts[1:]]]
+
+        strparts = infostock[1].split('$$')
+        strmsg = strparts[0].rstrip(' ').decode('string-escape')
+        strresps = [(s.find('&'), len(s)) for s in
+                    [p.strip(' ') for p in strparts[1:]]]
+
+        if [1 for (i, l) in idresps if i == -1]:
+            msgs.append("msgid has invalid choice missing '&'")
+        if [1 for (i, l) in idresps if l <= (i + 1)]:
+            msgs.append("msgid has invalid '&' followed by none")
+
+        if [1 for (i, l) in strresps if i == -1]:
+            msgs.append("msgstr has invalid choice missing '&'")
+        if [1 for (i, l) in strresps if l <= (i + 1)]:
+            msgs.append("msgstr has invalid '&' followed by none")
+
+        if (idmsg[-1] == '\n') != (strmsg[-1] == '\n'):
+            msgs.append("prompt text has different EOL")
+        if len(idparts) != len(strparts):
+            msgs.append("number of choices in msgstr is different from msgid")
+
 ####################
 
 import sys

tests/invalid-promptchoice.po

+# po file to test error checking of pickup.py around translation for
+# "ui.promptchoice()"
+
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=UTF-8\n"
+
+msgid ""
+"prompt text\n$$ &Largefile $$ &Normal file"
+msgstr ""
+"プロンプトテキスト末尾が、原文と違う(改行無し)$$&Largefile $$ &Normal file"
+
+msgid ""
+"prompt text\n$$ &Largefile $$ &Normal file"
+msgstr ""
+"プロンプトテキスト末尾が、原文と違う(改行無し)\n"
+"複数行$$&Largefile $$ &Normal file"
+
+msgid ""
+"prompt text$$ &Largefile $$ &Normal file"
+msgstr ""
+"プロンプトテキスト末尾が、原文と違う(改行あり)\n$$&Largefile $$ &Normal file"
+
+msgid ""
+"prompt text$$ &Largefile $$ &Normal file"
+msgstr ""
+"プロンプトテキスト末尾が、原文と違う(改行あり)\n"
+"複数行\n"
+"$$&Largefile $$ &Normal file"
+
+msgid ""
+"prompt text\n$$ &Largefile $$ &Normal file"
+msgstr ""
+"選択肢の数が、原文と違う(lesser)\n$$&Largefile"
+
+msgid ""
+"prompt text\n$$ &Largefile $$ &Normal file"
+msgstr ""
+"選択肢の数が、原文と違う(grater)\n$$&Largefile $$ &Normal file $$ &Invalid file"
+
+msgid ""
+"prompt text\n$$ &Largefile $$ Normal file"
+msgstr ""
+"& が無い選択肢(原文)\n$$&Largefile $$ &Normal file"
+
+msgid ""
+"prompt text\n$$ &Largefile $$ &Normal file"
+msgstr ""
+"& が無い選択肢(翻訳)\n$$&Largefile $$ Normal file"
+
+msgid ""
+"prompt text\n$$ Largefile& $$ &Normal file"
+msgstr ""
+"& に続く文字が無い選択肢(原文)\n$$ &Largefile $$ &Normal file"
+
+msgid ""
+"prompt text\n$$ &Largefile $$ &Normal file"
+msgstr ""
+"& に続く文字が無い選択肢(翻訳)\n$$Largefile& $$ &Normal file"