summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-07-19 14:34:42 +0200
committerBram Moolenaar <Bram@vim.org>2017-07-19 14:34:42 +0200
commit7f93703149a46980f1588ff6b819f52e13084141 (patch)
treef12d75a86ebd150fa34c6303c5d19875ffe3cbd5
parenta7df8c70c85c793bc4d75abc625d36883ab029cc (diff)
downloadvim-git-7f93703149a46980f1588ff6b819f52e13084141.tar.gz
patch 8.0.0734: the script to check translations can be improvedv8.0.0734
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)
-rw-r--r--src/po/check.vim37
-rw-r--r--src/version.c2
2 files changed, 39 insertions, 0 deletions
diff --git a/src/po/check.vim b/src/po/check.vim
index 256c5387d..ba98ae7aa 100644
--- a/src/po/check.vim
+++ b/src/po/check.vim
@@ -35,6 +35,7 @@ let s:save_wrapscan = &wrapscan
set nowrapscan
" Start at the first "msgid" line.
+let wsv = winsaveview()
1
/^msgid\>
@@ -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
+" 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
diff --git a/src/version.c b/src/version.c
index 49092c6b7..08d365645 100644
--- a/src/version.c
+++ b/src/version.c
@@ -770,6 +770,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 734,
+/**/
733,
/**/
732,