Mercurial > vim
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 |
rev | line source |
---|---|
461 | 1 " Vim script for checking .po files. |
2 " | |
1599 | 3 " Go through the file and verify that: |
4 " - All %...s items in "msgid" are identical to the ones in "msgstr". | |
5 " - An error or warning code in "msgid" matches the one in "msgstr". | |
461 | 6 |
7 if 1 " Only execute this if the eval feature is available. | |
8 | |
9 " Function to get a split line at the cursor. | |
10 " Used for both msgid and msgstr lines. | |
11 " Removes all text except % items and returns the result. | |
12 func! GetMline() | |
13 let idline = substitute(getline('.'), '"\(.*\)"$', '\1', '') | |
14 while line('.') < line('$') | |
15 + | |
16 let line = getline('.') | |
17 if line[0] != '"' | |
18 break | |
19 endif | |
20 let idline .= substitute(line, '"\(.*\)"$', '\1', '') | |
21 endwhile | |
22 | |
557 | 23 " remove '%', not used for formatting. |
24 let idline = substitute(idline, "'%'", '', 'g') | |
25 | |
1952 | 26 " remove '%' used for plural forms. |
27 let idline = substitute(idline, '\\nPlural-Forms: .\+;\\n', '', '') | |
28 | |
461 | 29 " remove everything but % items. |
30 return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g') | |
31 endfunc | |
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 | 37 " Start at the first "msgid" line. |
38 1 | |
39 /^msgid | |
40 let startline = line('.') | |
41 let error = 0 | |
42 | |
43 while 1 | |
44 if getline(line('.') - 1) !~ "no-c-format" | |
45 let fromline = GetMline() | |
46 if getline('.') !~ '^msgstr' | |
47 echo 'Missing "msgstr" in line ' . line('.') | |
48 let error = 1 | |
49 endif | |
50 let toline = GetMline() | |
51 if fromline != toline | |
52 echo 'Mismatching % in line ' . (line('.') - 1) | |
557 | 53 echo 'msgid: ' . fromline |
54 echo 'msgstr: ' . toline | |
461 | 55 let error = 1 |
56 endif | |
57 endif | |
58 | |
59 " Find next msgid. | |
60 " Wrap around at the end of the file, quit when back at the first one. | |
61 /^msgid | |
62 if line('.') == startline | |
63 break | |
64 endif | |
65 endwhile | |
66 | |
1599 | 67 " Check that error code in msgid matches the one in msgstr. |
68 " | |
69 " Examples of mismatches found with msgid "E123: ..." | |
70 " - msgstr "E321: ..." error code mismatch | |
71 " - msgstr "W123: ..." warning instead of error | |
72 " - msgstr "E123 ..." missing colon | |
73 " - msgstr "..." missing error code | |
74 " | |
75 1 | |
76 if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') > 0 | |
77 echo 'Mismatching error/warning code in line ' . line('.') | |
78 let error = 1 | |
79 endif | |
80 | |
461 | 81 if error == 0 |
82 echo "OK" | |
83 endif | |
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 | 88 endif |