summaryrefslogtreecommitdiff
path: root/src/po
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2005-08-04 21:29:45 +0000
committerBram Moolenaar <Bram@vim.org>2005-08-04 21:29:45 +0000
commit1d94f9b30eb9b90332d5043bc3c52b1841bcb7e6 (patch)
treec0c448b589daac7ff86d70bdc08dbea5e3ce509e /src/po
parent04a09c1975b02f88cbbddcb143bd081e99fc0007 (diff)
downloadvim-git-1d94f9b30eb9b90332d5043bc3c52b1841bcb7e6.tar.gz
updated for version 7.0123
Diffstat (limited to 'src/po')
-rw-r--r--src/po/check.vim58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/po/check.vim b/src/po/check.vim
new file mode 100644
index 000000000..a5f25aa0b
--- /dev/null
+++ b/src/po/check.vim
@@ -0,0 +1,58 @@
+" Vim script for checking .po files.
+"
+" Go through the file and verify that all %...s items in "msgid" are identical
+" to the ones in "msgstr".
+
+if 1 " Only execute this if the eval feature is available.
+
+" 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.
+func! GetMline()
+ let idline = substitute(getline('.'), '"\(.*\)"$', '\1', '')
+ while line('.') < line('$')
+ +
+ let line = getline('.')
+ if line[0] != '"'
+ break
+ endif
+ let idline .= substitute(line, '"\(.*\)"$', '\1', '')
+ endwhile
+
+ " remove everything but % items.
+ return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g')
+endfunc
+
+" Start at the first "msgid" line.
+1
+/^msgid
+let startline = line('.')
+let error = 0
+
+while 1
+ if getline(line('.') - 1) !~ "no-c-format"
+ let fromline = GetMline()
+ 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)
+ let error = 1
+ endif
+ endif
+
+ " Find next msgid.
+ " Wrap around at the end of the file, quit when back at the first one.
+ /^msgid
+ if line('.') == startline
+ break
+ endif
+endwhile
+
+if error == 0
+ echo "OK"
+endif
+
+endif