annotate src/po/check.vim @ 4238:26e59a39fdd9 v7.3.870

updated for version 7.3.870 Problem: Compiler warnings when using MingW 4.5.3. Solution: Do not use MAKEINTRESOURCE. Adjust #if. (Ken Takata)
author Bram Moolenaar <bram@vim.org>
date Tue, 19 Mar 2013 14:48:29 +0100
parents e037ee8698b3
children 580f57b07547
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 "
1599
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
3 " Go through the file and verify that:
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
4 " - All %...s items in "msgid" are identical to the ones in "msgstr".
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
5 " - An error or warning code in "msgid" matches the one in "msgstr".
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
6
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
7 if 1 " Only execute this if the eval feature is available.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
8
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
9 " Function to get a split line at the cursor.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
10 " Used for both msgid and msgstr lines.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
11 " Removes all text except % items and returns the result.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
12 func! GetMline()
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
13 let idline = substitute(getline('.'), '"\(.*\)"$', '\1', '')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
14 while line('.') < line('$')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
15 +
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
16 let line = getline('.')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
17 if line[0] != '"'
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
18 break
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
19 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
20 let idline .= substitute(line, '"\(.*\)"$', '\1', '')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
21 endwhile
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
22
557
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
23 " remove '%', not used for formatting.
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
24 let idline = substitute(idline, "'%'", '', 'g')
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
25
1952
6ddd55ac6ce5 updated for version 7.2-249
vimboss
parents: 1599
diff changeset
26 " remove '%' used for plural forms.
6ddd55ac6ce5 updated for version 7.2-249
vimboss
parents: 1599
diff changeset
27 let idline = substitute(idline, '\\nPlural-Forms: .\+;\\n', '', '')
6ddd55ac6ce5 updated for version 7.2-249
vimboss
parents: 1599
diff changeset
28
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
29 " remove everything but % items.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
30 return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
31 endfunc
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
32
2484
e037ee8698b3 Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 1952
diff changeset
33 " This only works when 'wrapscan' is set.
e037ee8698b3 Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 1952
diff changeset
34 let s:save_wrapscan = &wrapscan
e037ee8698b3 Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 1952
diff changeset
35 set wrapscan
e037ee8698b3 Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 1952
diff changeset
36
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
37 " Start at the first "msgid" line.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
38 1
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
39 /^msgid
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
40 let startline = line('.')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
41 let error = 0
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
42
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
43 while 1
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
44 if getline(line('.') - 1) !~ "no-c-format"
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
45 let fromline = GetMline()
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
46 if getline('.') !~ '^msgstr'
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
47 echo 'Missing "msgstr" in line ' . line('.')
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
48 let error = 1
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
49 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
50 let toline = GetMline()
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
51 if fromline != toline
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
52 echo 'Mismatching % in line ' . (line('.') - 1)
557
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
53 echo 'msgid: ' . fromline
862863033fdd updated for version 7.0158
vimboss
parents: 461
diff changeset
54 echo 'msgstr: ' . toline
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
55 let error = 1
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
56 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
57 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
58
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
59 " Find next msgid.
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
60 " 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
61 /^msgid
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
62 if line('.') == startline
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
63 break
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
64 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
65 endwhile
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
66
1599
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
67 " Check that error code in msgid matches the one in msgstr.
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
68 "
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
69 " Examples of mismatches found with msgid "E123: ..."
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
70 " - msgstr "E321: ..." error code mismatch
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
71 " - msgstr "W123: ..." warning instead of error
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
72 " - msgstr "E123 ..." missing colon
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
73 " - msgstr "..." missing error code
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
74 "
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
75 1
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
76 if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') > 0
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
77 echo 'Mismatching error/warning code in line ' . line('.')
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
78 let error = 1
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
79 endif
2f016b638c0c updated for version 7.1-312
vimboss
parents: 557
diff changeset
80
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
81 if error == 0
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
82 echo "OK"
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
83 endif
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
84
2484
e037ee8698b3 Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 1952
diff changeset
85 let &wrapscan = s:save_wrapscan
e037ee8698b3 Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 1952
diff changeset
86 unlet s:save_wrapscan
e037ee8698b3 Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents: 1952
diff changeset
87
461
f98374445f66 updated for version 7.0123
vimboss
parents:
diff changeset
88 endif