Mercurial > vim
annotate src/po/check.vim @ 24375:fe4b6fc7149c v8.2.2728
patch 8.2.2728: special key names don't work if 'isident' is cleared
Commit: https://github.com/vim/vim/commit/e3d1f4c982bd0fe05496448d7868268c75ff7bfb
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Apr 6 20:21:59 2021 +0200
patch 8.2.2728: special key names don't work if 'isident' is cleared
Problem: Special key names don't work if 'isident' is cleared.
Solution: Add vim_isNormalIDc() and use it for special key names.
(closes #2389)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 06 Apr 2021 20:30:05 +0200 |
parents | 4d5081260d5a |
children | 7fb63ad3a9ab |
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') | |
21998
4d5081260d5a
patch 8.2.1548: cannot move position of "%%" in message translations
Bram Moolenaar <Bram@vim.org>
parents:
18625
diff
changeset
|
25 let idline = substitute(idline, "%%", '', 'g') |
557 | 26 |
1952 | 27 " remove '%' used for plural forms. |
28 let idline = substitute(idline, '\\nPlural-Forms: .\+;\\n', '', '') | |
29 | |
461 | 30 " remove everything but % items. |
31 return substitute(idline, '[^%]*\(%[-+ #''.0-9*]*l\=[dsuxXpoc%]\)\=', '\1', 'g') | |
32 endfunc | |
33 | |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
34 " This only works when 'wrapscan' is not set. |
2484
e037ee8698b3
Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents:
1952
diff
changeset
|
35 let s:save_wrapscan = &wrapscan |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
36 set nowrapscan |
2484
e037ee8698b3
Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents:
1952
diff
changeset
|
37 |
461 | 38 " Start at the first "msgid" line. |
11702
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
39 let wsv = winsaveview() |
461 | 40 1 |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
41 /^msgid\> |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
42 |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
43 " When an error is detected this is set to the line number. |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
44 " Note: this is used in the Makefile. |
461 | 45 let error = 0 |
46 | |
47 while 1 | |
18625
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
48 let lnum = line('.') |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
49 if getline(lnum) =~ 'msgid "Text;.*;"' |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
50 if getline(lnum + 1) !~ '^msgstr "\([^;]\+;\)\+"' |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
51 echomsg 'Mismatching ; in line ' . (lnum + 1) |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
52 echomsg 'Did you forget the trailing semicolon?' |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
53 if error == 0 |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
54 let error = lnum + 1 |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
55 endif |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
56 endif |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
57 endif |
57927799c27e
patch 8.1.2305: no warning for wrong entry in translations
Bram Moolenaar <Bram@vim.org>
parents:
14187
diff
changeset
|
58 |
461 | 59 if getline(line('.') - 1) !~ "no-c-format" |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
60 " go over the "msgid" and "msgid_plural" lines |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
61 let prevfromline = 'foobar' |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
62 while 1 |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
63 let fromline = GetMline() |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
64 if prevfromline != 'foobar' && prevfromline != fromline |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
65 echomsg 'Mismatching % in line ' . (line('.') - 1) |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
66 echomsg 'msgid: ' . prevfromline |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
67 echomsg 'msgid ' . fromline |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
68 if error == 0 |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
69 let error = line('.') |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
70 endif |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
71 endif |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
72 if getline('.') !~ 'msgid_plural' |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
73 break |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
74 endif |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
75 let prevfromline = fromline |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
76 endwhile |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
77 |
461 | 78 if getline('.') !~ '^msgstr' |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
79 echomsg 'Missing "msgstr" in line ' . line('.') |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
80 if error == 0 |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
81 let error = line('.') |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
82 endif |
461 | 83 endif |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
84 |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
85 " check all the 'msgstr' lines |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
86 while getline('.') =~ '^msgstr' |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
87 let toline = GetMline() |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
88 if fromline != toline |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
89 echomsg 'Mismatching % in line ' . (line('.') - 1) |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
90 echomsg 'msgid: ' . fromline |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
91 echomsg 'msgstr: ' . toline |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
92 if error == 0 |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
93 let error = line('.') |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
94 endif |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
95 endif |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
96 if line('.') == line('$') |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
97 break |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
98 endif |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
99 endwhile |
461 | 100 endif |
101 | |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
102 " Find next msgid. Quit when there is no more. |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
103 let lnum = line('.') |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
104 silent! /^msgid\> |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
105 if line('.') == lnum |
461 | 106 break |
107 endif | |
108 endwhile | |
109 | |
1599 | 110 " Check that error code in msgid matches the one in msgstr. |
111 " | |
112 " Examples of mismatches found with msgid "E123: ..." | |
113 " - msgstr "E321: ..." error code mismatch | |
114 " - msgstr "W123: ..." warning instead of error | |
115 " - msgstr "E123 ..." missing colon | |
116 " - msgstr "..." missing error code | |
117 " | |
118 1 | |
119 if search('msgid "\("\n"\)\?\([EW][0-9]\+:\).*\nmsgstr "\("\n"\)\?[^"]\@=\2\@!') > 0 | |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
120 echomsg 'Mismatching error/warning code in line ' . line('.') |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
121 if error == 0 |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
122 let error = line('.') |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
123 endif |
1599 | 124 endif |
125 | |
11702
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
126 func! CountNl(first, last) |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
127 let nl = 0 |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
128 for lnum in range(a:first, a:last) |
11828
5a07a3ff56c1
patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents:
11702
diff
changeset
|
129 let nl += count(getline(lnum), "\n") |
11702
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
130 endfor |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
131 return nl |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
132 endfunc |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
133 |
11828
5a07a3ff56c1
patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents:
11702
diff
changeset
|
134 " Check that the \n at the end of the msgid line is also present in the msgstr |
11702
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
135 " line. Skip over the header. |
13812
9d6cd12ae7bc
patch 8.0.1778: script to check translations does not always work
Christian Brabandt <cb@256bit.org>
parents:
12756
diff
changeset
|
136 1 |
11702
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
137 /^"MIME-Version: |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
138 while 1 |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
139 let lnum = search('^msgid\>') |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
140 if lnum <= 0 |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
141 break |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
142 endif |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
143 let strlnum = search('^msgstr\>') |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
144 let end = search('^$') |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
145 if end <= 0 |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
146 let end = line('$') + 1 |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
147 endif |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
148 let origcount = CountNl(lnum, strlnum - 1) |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
149 let transcount = CountNl(strlnum, end - 1) |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
150 " Allow for a few more or less line breaks when there are 2 or more |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
151 if origcount != transcount && (origcount <= 2 || transcount <= 2) |
11828
5a07a3ff56c1
patch 8.0.0794: checking translations fails with multiple NL
Christian Brabandt <cb@256bit.org>
parents:
11702
diff
changeset
|
152 echomsg 'Mismatching "\n" in line ' . line('.') |
11702
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
153 if error == 0 |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
154 let error = lnum |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
155 endif |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
156 endif |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
157 endwhile |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
158 |
11900
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
159 " Check that the file is well formed according to msgfmts understanding |
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
160 if executable("msgfmt") |
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
161 let filename = expand("%") |
12756
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
11910
diff
changeset
|
162 " Newer msgfmt does not take OLD_PO_FILE_INPUT argument, must be in |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
11910
diff
changeset
|
163 " environment. |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
11910
diff
changeset
|
164 let $OLD_PO_FILE_INPUT = 'yes' |
3b26420fc639
Long overdue runtime update.
Christian Brabandt <cb@256bit.org>
parents:
11910
diff
changeset
|
165 let a = system("msgfmt --statistics " . filename) |
11900
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
166 if v:shell_error != 0 |
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
167 let error = matchstr(a, filename.':\zs\d\+\ze:')+0 |
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
168 for line in split(a, '\n') | echomsg line | endfor |
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
169 endif |
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
170 endif |
39e46ae74c69
patch 8.0.0830: translating messages is not ideal
Christian Brabandt <cb@256bit.org>
parents:
11828
diff
changeset
|
171 |
13938
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
172 " Check that the plural form is properly initialized |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
173 1 |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
174 let plural = search('^msgid_plural ', 'n') |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
175 if (plural && search('^"Plural-Forms: ', 'n') == 0) || (plural && search('^msgstr\[0\] ".\+"', 'n') != plural + 1) |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
176 if search('^"Plural-Forms: ', 'n') == 0 |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
177 echomsg "Missing Plural header" |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
178 if error == 0 |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
179 let error = search('\(^"[A-Za-z-_]\+: .*\\n"\n\)\+\zs', 'n') - 1 |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
180 endif |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
181 elseif error == 0 |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
182 let error = plural |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
183 endif |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
184 elseif !plural && search('^"Plural-Forms: ', 'n') |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
185 " We allow for a stray plural header, msginit adds one. |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
186 endif |
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
187 |
14187
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
188 " Check that 8bit encoding is used instead of 8-bit |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
189 let cte = search('^"Content-Transfer-Encoding:\s\+8-bit', 'n') |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
190 let ctc = search('^"Content-Type:.*;\s\+\<charset=[iI][sS][oO]_', 'n') |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
191 let ctu = search('^"Content-Type:.*;\s\+\<charset=utf-8', 'n') |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
192 if cte |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
193 echomsg "Content-Transfer-Encoding should be 8bit instead of 8-bit" |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
194 " TODO: make this an error |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
195 " if error == 0 |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
196 " let error = cte |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
197 " endif |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
198 elseif ctc |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
199 echomsg "Content-Type charset should be 'ISO-...' instead of 'ISO_...'" |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
200 " TODO: make this an error |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
201 " if error == 0 |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
202 " let error = ct |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
203 " endif |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
204 elseif ctu |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
205 echomsg "Content-Type charset should be 'UTF-8' instead of 'utf-8'" |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
206 " TODO: make this an error |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
207 " if error == 0 |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
208 " let error = ct |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
209 " endif |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
210 endif |
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
211 |
13938
b9db0bc9b8f9
patch 8.0.1839: script to check .po file doesn't check for plural header
Christian Brabandt <cb@256bit.org>
parents:
13812
diff
changeset
|
212 |
461 | 213 if error == 0 |
11702
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
214 " If all was OK restore the view. |
48a95b916781
patch 8.0.0734: the script to check translations can be improved
Christian Brabandt <cb@256bit.org>
parents:
9963
diff
changeset
|
215 call winrestview(wsv) |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
216 echomsg "OK" |
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
217 else |
14187
b79453d0d01c
patch 8.1.0111: .po files do not use recommended names
Christian Brabandt <cb@256bit.org>
parents:
13938
diff
changeset
|
218 " Put the cursor on the line with the error. |
9963
580f57b07547
commit https://github.com/vim/vim/commit/ec42059b78c1932a44f2bf36ac982109884dc7c7
Christian Brabandt <cb@256bit.org>
parents:
2484
diff
changeset
|
219 exe error |
461 | 220 endif |
221 | |
2484
e037ee8698b3
Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents:
1952
diff
changeset
|
222 let &wrapscan = s:save_wrapscan |
e037ee8698b3
Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents:
1952
diff
changeset
|
223 unlet s:save_wrapscan |
e037ee8698b3
Set 'wrapscan' when checking the .po files. (Mike Williams)
Bram Moolenaar <bram@vim.org>
parents:
1952
diff
changeset
|
224 |
461 | 225 endif |