]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1586: error for using two messages with ngettext() differing in "%" v9.0.1586
authorBram Moolenaar <Bram@vim.org>
Sun, 28 May 2023 17:39:55 +0000 (18:39 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 28 May 2023 17:39:55 +0000 (18:39 +0100)
Problem:    Checking translations gives an error for using two messages with
            ngettext() that differ in "%" items.
Solution:   Adjust the check script to tolerate omitting one "%" item.

src/po/check.vim
src/version.c

index a01874cce7883bc00673146ee73854f0d034e366..b2a5fd582eb7fd7b0baf404abb4d6d9a13ae4fe0 100644 (file)
@@ -6,6 +6,9 @@
 
 if 1   " Only execute this if the eval feature is available.
 
+" using line continuation
+set cpo&vim
+
 " Function to get a split line at the cursor.
 " Used for both msgid and msgstr lines.
 " Removes all text except % items and returns the result.
@@ -59,12 +62,18 @@ while 1
   if getline(line('.') - 1) !~ "no-c-format"
     " go over the "msgid" and "msgid_plural" lines
     let prevfromline = 'foobar'
+    let plural = 0
     while 1
+      if getline('.') =~ 'msgid_plural'
+       let plural += 1
+      endif
       let fromline = GetMline()
       if prevfromline != 'foobar' && prevfromline != fromline
+           \ && (plural != 1
+           \     || count(prevfromline, '%') + 1 != count(fromline, '%'))
        echomsg 'Mismatching % in line ' . (line('.') - 1)
        echomsg 'msgid: ' . prevfromline
-       echomsg 'msgid ' . fromline
+       echomsg 'msgid: ' . fromline
        if error == 0
          let error = line('.')
        endif
@@ -86,6 +95,7 @@ while 1
     while getline('.') =~ '^msgstr'
       let toline = GetMline()
       if fromline != toline
+           \ && (plural == 0 || count(fromline, '%') != count(toline, '%') + 1)
        echomsg 'Mismatching % in line ' . (line('.') - 1)
        echomsg 'msgid: ' . fromline
        echomsg 'msgstr: ' . toline
index 27e558a52b906b06fab1738a53f5199dfb854993..fdb7716a989c1035509054d1da79d202b19d33aa 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1586,
 /**/
     1585,
 /**/