summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-08-26 15:51:53 +0200
committerBram Moolenaar <Bram@vim.org>2016-08-26 15:51:53 +0200
commitec42059b78c1932a44f2bf36ac982109884dc7c7 (patch)
treee985cbfc921085d6065c6dbdadc3bb266f3cff89
parent54b6352c6f0617ff9c963588ccc7d31815348029 (diff)
downloadvim-git-ec42059b78c1932a44f2bf36ac982109884dc7c7.tar.gz
patch 7.4.2255v7.4.2255
Problem: The script that checks translations can't handle plurals. Solution: Check for plural msgid and msgstr entries. Leave the cursor on the first error.
-rw-r--r--src/po/check.vim76
-rw-r--r--src/version.c2
2 files changed, 57 insertions, 21 deletions
diff --git a/src/po/check.vim b/src/po/check.vim
index 5a3a0e3f4..256c5387d 100644
--- a/src/po/check.vim
+++ b/src/po/check.vim
@@ -30,36 +30,66 @@ func! GetMline()
return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g')
endfunc
-" This only works when 'wrapscan' is set.
+" This only works when 'wrapscan' is not set.
let s:save_wrapscan = &wrapscan
-set wrapscan
+set nowrapscan
" Start at the first "msgid" line.
1
-/^msgid
-let startline = line('.')
+/^msgid\>
+
+" When an error is detected this is set to the line number.
+" Note: this is used in the Makefile.
let error = 0
while 1
if getline(line('.') - 1) !~ "no-c-format"
- let fromline = GetMline()
+ " go over the "msgid" and "msgid_plural" lines
+ let prevfromline = 'foobar'
+ while 1
+ let fromline = GetMline()
+ if prevfromline != 'foobar' && prevfromline != fromline
+ echomsg 'Mismatching % in line ' . (line('.') - 1)
+ echomsg 'msgid: ' . prevfromline
+ echomsg 'msgid ' . fromline
+ if error == 0
+ let error = line('.')
+ endif
+ endif
+ if getline('.') !~ 'msgid_plural'
+ break
+ endif
+ let prevfromline = fromline
+ endwhile
+
if getline('.') !~ '^msgstr'
- echo 'Missing "msgstr" in line ' . line('.')
- let error = 1
- endif
- let toline = GetMline()
- if fromline != toline
- echo 'Mismatching % in line ' . (line('.') - 1)
- echo 'msgid: ' . fromline
- echo 'msgstr: ' . toline
- let error = 1
+ echomsg 'Missing "msgstr" in line ' . line('.')
+ if error == 0
+ let error = line('.')
+ endif
endif
+
+ " check all the 'msgstr' lines
+ while getline('.') =~ '^msgstr'
+ let toline = GetMline()
+ if fromline != toline
+ echomsg 'Mismatching % in line ' . (line('.') - 1)
+ echomsg 'msgid: ' . fromline
+ echomsg 'msgstr: ' . toline
+ if error == 0
+ let error = line('.')
+ endif
+ endif
+ if line('.') == line('$')
+ break
+ endif
+ endwhile
endif
- " Find next msgid.
- " Wrap around at the end of the file, quit when back at the first one.
- /^msgid
- if line('.') == startline
+ " Find next msgid. Quit when there is no more.
+ let lnum = line('.')
+ silent! /^msgid\>
+ if line('.') == lnum
break
endif
endwhile
@@ -74,12 +104,16 @@ endwhile
"
1
if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') > 0
- echo 'Mismatching error/warning code in line ' . line('.')
- let error = 1
+ echomsg 'Mismatching error/warning code in line ' . line('.')
+ if error == 0
+ let error = line('.')
+ endif
endif
if error == 0
- echo "OK"
+ echomsg "OK"
+else
+ exe error
endif
let &wrapscan = s:save_wrapscan
diff --git a/src/version.c b/src/version.c
index 15e75e6ad..0196282a4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -764,6 +764,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2255,
+/**/
2254,
/**/
2253,