Skip to content

Commit

Permalink
patch 8.0.0734: the script to check translations can be improved
Browse files Browse the repository at this point in the history
Problem:    The script to check translations can be improved.
Solution:   Restore the view when no errors are found.  Check for matching
            line break at the end of the message. (Christian Brabandt)
  • Loading branch information
brammool committed Jul 19, 2017
1 parent a7df8c7 commit 7f93703
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/po/check.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ let s:save_wrapscan = &wrapscan
set nowrapscan

" Start at the first "msgid" line.
let wsv = winsaveview()
1
/^msgid\>

Expand Down Expand Up @@ -110,7 +111,43 @@ if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!')
endif
endif

func! CountNl(first, last)
let nl = 0
for lnum in range(a:first, a:last)
if getline(lnum) =~ '\\n'
let nl += 1
endif
endfor
return nl
endfunc

" Check that the \n at the end of the msid line is also present in the msgstr

This comment has been minimized.

Copy link
@h-east

h-east Jul 21, 2017

Contributor

typo found.
s/msid/msgid/

This comment has been minimized.

Copy link
@brammool

brammool via email Jul 21, 2017

Author Contributor
" line. Skip over the header.
/^"MIME-Version:
while 1
let lnum = search('^msgid\>')
if lnum <= 0
break
endif
let strlnum = search('^msgstr\>')
let end = search('^$')
if end <= 0
let end = line('$') + 1
endif
let origcount = CountNl(lnum, strlnum - 1)
let transcount = CountNl(strlnum, end - 1)
" Allow for a few more or less line breaks when there are 2 or more
if origcount != transcount && (origcount <= 2 || transcount <= 2)
echomsg 'Mismatching "\\n" in line ' . line('.')
if error == 0
let error = lnum
endif
endif
endwhile

if error == 0
" If all was OK restore the view.
call winrestview(wsv)
echomsg "OK"
else
exe error
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
734,
/**/
733,
/**/
Expand Down

0 comments on commit 7f93703

Please sign in to comment.