Code

Translations. Check-markup msgctxt support added.
authorJazzyNico <nicoduf@yahoo.fr>
Tue, 25 May 2010 16:07:52 +0000 (18:07 +0200)
committerJazzyNico <nicoduf@yahoo.fr>
Tue, 25 May 2010 16:07:52 +0000 (18:07 +0200)
po/check-markup

index b5a103ebf6978652010263ad9ba7b21c58d13816..459e7e2e7b6692019305d5f1f7a8ac0f7bd27355 100755 (executable)
@@ -160,15 +160,37 @@ ENTRY: while(<>) {
            next ENTRY;
        }
 
-       s/"\n"//g;
-
-       if (!m{\A${com}*msgid[^\n]*\n${com}*msgstr[^\n]*\n${com}*\Z} &&
-           !m{\A${com}*msgid[^\n]*\n${com}*msgid_plural[^\n]*\n${com}*(msgstr\[[^\n]*\n${com}*)+\Z}) {
+       # Concatenate multi-line string literals.
+       s/"\n\s*"//g;
+
+       if (!m{\A${com}*
+              (?:msgctxt[^\n]*\n)?
+              msgid[^\n]*\n
+              ${com}*
+              (?:
+                  msgstr[^\n]*\n
+                  ${com}*
+                | msgid_plural[^\n]*\n
+                  ${com}*
+                  (?:msgstr\[[^\n]*\n${com}*)+
+               )\Z}x)
+       {
            po_error('Not in msg format');
            next ENTRY;
        }
-       if (!m{\A${com}*msgid ${str}\s*\n${com}*msgstr ${str}\s*\n${com}*\Z} &&
-              !m{\A${com}*msgid ${str}\s*\n${com}*msgid_plural ${str}\s*\n${com}*(msgstr\[\d+\] ${str}\s*\n${com}*)+\Z}) {
+       if (!m{
+               \A${com}*
+               (?:msgctxt\ ${str}\s*\n)?
+               msgid\ ${str}\s*\n
+               ${com}*
+               (?:
+                   msgstr\ ${str}\s*\n
+                   ${com}*
+                 | msgid_plural\ ${str}\s*\n
+                   ${com}*
+                   (?:msgstr\[\d+\]\ ${str}\s*\n${com}*)+
+               )\Z}x)
+       {
            po_error('Mismatched quotes');
            next ENTRY;
        }
@@ -192,14 +214,26 @@ ENTRY: while(<>) {
        }
 
 
-       if (m{\A${com}*msgid\ (${str})\n
-             ${com}*msgstr\ (${str})\n
-             ${com}*\Z}x) {
+       if (m{\A
+               ${com}*
+               (?:msgctxt\ ${str}\s*\n)?
+               msgid\ (${str})\n
+               ${com}*
+               msgstr\ (${str})\n
+               ${com}*
+             \Z}x)
+       {
            check_strs($is_pango_format, $1, $2) or next ENTRY;
        }
-       elsif (m{\A${com}*msgid\ (${str})\n
-                ${com}*msgid_plural\ (${str})\n
-                ((?:${com}*msgstr\[\d+\]\ ${str}\n${com}*)+)\Z}x) {
+       elsif (m{\A
+                  ${com}*
+                  (?:msgctxt\ ${str}\s*\n)?
+                  msgid\ (${str})\n
+                  ${com}*
+                  msgid_plural\ (${str})\n
+                  ((?:${com}*msgstr\[\d+\]\ ${str}\n${com}*)+)
+                \Z}x)
+       {
            my ($s1, $s2, $rest) = ($1, $2, $3);
            my @strs = ($s1, $s2);
            while ($rest =~ s/\A${com}*msgstr\[\d+\]\ (${str})\n${com}*//) {