1 " Vim script for checking .po files.
3 " Go through the file and verify that all %...s items in "msgid" are identical
4 " to the ones in "msgstr".
6 if 1 " Only execute this if the eval feature is available.
8 " Function to get a split line at the cursor.
9 " Used for both msgid and msgstr lines.
10 " Removes all text except % items and returns the result.
12 let idline = substitute(getline('.'), '"\(.*\)"$', '\1', '')
13 while line('.') < line('$')
15 let line = getline('.')
19 let idline .= substitute(line, '"\(.*\)"$', '\1', '')
22 " remove '%', not used for formatting.
23 let idline = substitute(idline, "'%'", '', 'g')
25 " remove everything but % items.
26 return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g')
29 " Start at the first "msgid" line.
32 let startline = line('.')
36 if getline(line('.') - 1) !~ "no-c-format"
37 let fromline = GetMline()
38 if getline('.') !~ '^msgstr'
39 echo 'Missing "msgstr" in line ' . line('.')
42 let toline = GetMline()
44 echo 'Mismatching % in line ' . (line('.') - 1)
45 echo 'msgid: ' . fromline
46 echo 'msgstr: ' . toline
52 " Wrap around at the end of the file, quit when back at the first one.
54 if line('.') == startline