vim-patch:7.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.

ec42059b78
This commit is contained in:
lonerover
2017-03-17 22:48:42 +08:00
parent 9abef7ded9
commit a5481957c6
2 changed files with 56 additions and 22 deletions

View File

@@ -33,36 +33,66 @@ func! GetMline()
return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g') return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g')
endfunc endfunc
" This only works when 'wrapscan' is set. " This only works when 'wrapscan' is not set.
let s:save_wrapscan = &wrapscan let s:save_wrapscan = &wrapscan
set wrapscan set nowrapscan
" Start at the first "msgid" line. " Start at the first "msgid" line.
1 1
/^msgid /^msgid\>
let startline = line('.')
" When an error is detected this is set to the line number.
" Note: this is used in the Makefile.
let error = 0 let error = 0
while 1 while 1
if getline(line('.') - 1) !~ "no-c-format" if getline(line('.') - 1) !~ "no-c-format"
" go over the "msgid" and "msgid_plural" lines
let prevfromline = 'foobar'
while 1
let fromline = GetMline() let fromline = GetMline()
if getline('.') !~ '^msgstr' if prevfromline != 'foobar' && prevfromline != fromline
echo 'Missing "msgstr" in line ' . line('.') echomsg 'Mismatching % in line ' . (line('.') - 1)
let error = 1 echomsg 'msgid: ' . prevfromline
echomsg 'msgid ' . fromline
if error == 0
let error = line('.')
endif endif
let toline = GetMline() endif
if fromline != toline if getline('.') !~ 'msgid_plural'
echo 'Mismatching % in line ' . (line('.') - 1) break
echo 'msgid: ' . fromline endif
echo 'msgstr: ' . toline let prevfromline = fromline
let error = 1 endwhile
if getline('.') !~ '^msgstr'
echomsg 'Missing "msgstr" in line ' . line('.')
if error == 0
let error = line('.')
endif endif
endif endif
" Find next msgid. " check all the 'msgstr' lines
" Wrap around at the end of the file, quit when back at the first one. while getline('.') =~ '^msgstr'
/^msgid let toline = GetMline()
if line('.') == startline 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. Quit when there is no more.
let lnum = line('.')
silent! /^msgid\>
if line('.') == lnum
break break
endif endif
endwhile endwhile
@@ -77,12 +107,16 @@ endwhile
" "
1 1
if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') > 0 if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') > 0
echo 'Mismatching error/warning code in line ' . line('.') echomsg 'Mismatching error/warning code in line ' . line('.')
let error = 1 if error == 0
let error = line('.')
endif
endif endif
if error == 0 if error == 0
echo "OK" echomsg "OK"
else
exe error
endif endif
redir END redir END

View File

@@ -186,7 +186,7 @@ static int included_patches[] = {
// 2258 NA // 2258 NA
// 2257 NA // 2257 NA
// 2256, // 2256,
// 2255, 2255,
// 2254 NA // 2254 NA
// 2253 NA // 2253 NA
// 2252 NA // 2252 NA