annotate src/po/check.vim @ 1291:f12d38ee49de v7.1.006

updated for version 7.1-006
author vimboss
date Tue, 19 Jun 2007 13:36:52 +0000
parents 862863033fdd
children 2f016b638c0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
1 " Vim script for checking .po files.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
2 "
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
3 " Go through the file and verify that all %...s items in "msgid" are identical
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
4 " to the ones in "msgstr".
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
5
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
6 if 1 " Only execute this if the eval feature is available.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
7
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
8 " Function to get a split line at the cursor.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
9 " Used for both msgid and msgstr lines.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
10 " Removes all text except % items and returns the result.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
11 func! GetMline()
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
12 let idline = substitute(getline('.'), '"\(.*\)"$', '\1', '')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
13 while line('.') < line('$')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
14 +
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
15 let line = getline('.')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
16 if line[0] != '"'
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
17 break
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
18 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
19 let idline .= substitute(line, '"\(.*\)"$', '\1', '')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
20 endwhile
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
21
557
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
22 " remove '%', not used for formatting.
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
23 let idline = substitute(idline, "'%'", '', 'g')
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
24
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
25 " remove everything but % items.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
26 return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
27 endfunc
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
28
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
29 " Start at the first "msgid" line.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
30 1
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
31 /^msgid
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
32 let startline = line('.')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
33 let error = 0
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
34
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
35 while 1
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
36 if getline(line('.') - 1) !~ "no-c-format"
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
37 let fromline = GetMline()
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
38 if getline('.') !~ '^msgstr'
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
39 echo 'Missing "msgstr" in line ' . line('.')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
40 let error = 1
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
41 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
42 let toline = GetMline()
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
43 if fromline != toline
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
44 echo 'Mismatching % in line ' . (line('.') - 1)
557
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
45 echo 'msgid: ' . fromline
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
46 echo 'msgstr: ' . toline
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
47 let error = 1
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
48 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
49 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
50
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
51 " Find next msgid.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
52 " Wrap around at the end of the file, quit when back at the first one.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
53 /^msgid
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
54 if line('.') == startline
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
55 break
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
56 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
57 endwhile
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
58
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
59 if error == 0
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
60 echo "OK"
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
61 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
62
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
63 endif