Plugins/CheckerPlugins/CodeStyleChecker/translations.py

branch
BgService
changeset 3413
5e63f809732a
child 3443
7d919fd299f6
equal deleted inserted replaced
3412:9364dab2d472 3413:5e63f809732a
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2014 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing message translations for the code style plugin messages.
8 """
9
10 from PyQt4.QtCore import QCoreApplication
11
12 __all__ = ["getTranslatedMessage"]
13
14 _messages = {
15 "E101": QCoreApplication.translate(
16 "pep8",
17 "indentation contains mixed spaces and tabs"),
18 "E111": QCoreApplication.translate(
19 "pep8",
20 "indentation is not a multiple of four"),
21 "E112": QCoreApplication.translate(
22 "pep8",
23 "expected an indented block"),
24 "E113": QCoreApplication.translate(
25 "pep8",
26 "unexpected indentation"),
27 "E121": QCoreApplication.translate(
28 "pep8",
29 "continuation line indentation is not a multiple of four"),
30 "E122": QCoreApplication.translate(
31 "pep8",
32 "continuation line missing indentation or outdented"),
33 "E123": QCoreApplication.translate(
34 "pep8",
35 "closing bracket does not match indentation of opening"
36 " bracket's line"),
37 "E124": QCoreApplication.translate(
38 "pep8",
39 "closing bracket does not match visual indentation"),
40 "E125": QCoreApplication.translate(
41 "pep8",
42 "continuation line does not distinguish itself from next"
43 " logical line"),
44 "E126": QCoreApplication.translate(
45 "pep8",
46 "continuation line over-indented for hanging indent"),
47 "E127": QCoreApplication.translate(
48 "pep8",
49 "continuation line over-indented for visual indent"),
50 "E128": QCoreApplication.translate(
51 "pep8",
52 "continuation line under-indented for visual indent"),
53 "E133": QCoreApplication.translate(
54 "pep8",
55 "closing bracket is missing indentation"),
56 "W191": QCoreApplication.translate(
57 "pep8",
58 "indentation contains tabs"),
59 "E201": QCoreApplication.translate(
60 "pep8",
61 "whitespace after '{0}'"),
62 "E202": QCoreApplication.translate(
63 "pep8",
64 "whitespace before '{0}'"),
65 "E203": QCoreApplication.translate(
66 "pep8",
67 "whitespace before '{0}'"),
68 "E211": QCoreApplication.translate(
69 "pep8",
70 "whitespace before '{0}'"),
71 "E221": QCoreApplication.translate(
72 "pep8",
73 "multiple spaces before operator"),
74 "E222": QCoreApplication.translate(
75 "pep8",
76 "multiple spaces after operator"),
77 "E223": QCoreApplication.translate(
78 "pep8",
79 "tab before operator"),
80 "E224": QCoreApplication.translate(
81 "pep8",
82 "tab after operator"),
83 "E225": QCoreApplication.translate(
84 "pep8",
85 "missing whitespace around operator"),
86 "E226": QCoreApplication.translate(
87 "pep8",
88 "missing whitespace around arithmetic operator"),
89 "E227": QCoreApplication.translate(
90 "pep8",
91 "missing whitespace around bitwise or shift operator"),
92 "E228": QCoreApplication.translate(
93 "pep8",
94 "missing whitespace around modulo operator"),
95 "E231": QCoreApplication.translate(
96 "pep8",
97 "missing whitespace after '{0}'"),
98 "E241": QCoreApplication.translate(
99 "pep8",
100 "multiple spaces after '{0}'"),
101 "E242": QCoreApplication.translate(
102 "pep8",
103 "tab after '{0}'"),
104 "E251": QCoreApplication.translate(
105 "pep8",
106 "unexpected spaces around keyword / parameter equals"),
107 "E261": QCoreApplication.translate(
108 "pep8",
109 "at least two spaces before inline comment"),
110 "E262": QCoreApplication.translate(
111 "pep8",
112 "inline comment should start with '# '"),
113 "E271": QCoreApplication.translate(
114 "pep8",
115 "multiple spaces after keyword"),
116 "E272": QCoreApplication.translate(
117 "pep8",
118 "multiple spaces before keyword"),
119 "E273": QCoreApplication.translate(
120 "pep8",
121 "tab after keyword"),
122 "E274": QCoreApplication.translate(
123 "pep8",
124 "tab before keyword"),
125 "W291": QCoreApplication.translate(
126 "pep8",
127 "trailing whitespace"),
128 "W292": QCoreApplication.translate(
129 "pep8",
130 "no newline at end of file"),
131 "W293": QCoreApplication.translate(
132 "pep8",
133 "blank line contains whitespace"),
134 "E301": QCoreApplication.translate(
135 "pep8",
136 "expected 1 blank line, found 0"),
137 "E302": QCoreApplication.translate(
138 "pep8",
139 "expected 2 blank lines, found {0}"),
140 "E303": QCoreApplication.translate(
141 "pep8",
142 "too many blank lines ({0})"),
143 "E304": QCoreApplication.translate(
144 "pep8",
145 "blank lines found after function decorator"),
146 "W391": QCoreApplication.translate(
147 "pep8",
148 "blank line at end of file"),
149 "E401": QCoreApplication.translate(
150 "pep8",
151 "multiple imports on one line"),
152 "E501": QCoreApplication.translate(
153 "pep8",
154 "line too long ({0} > {1} characters)"),
155 "E502": QCoreApplication.translate(
156 "pep8",
157 "the backslash is redundant between brackets"),
158 "W601": QCoreApplication.translate(
159 "pep8",
160 ".has_key() is deprecated, use 'in'"),
161 "W602": QCoreApplication.translate(
162 "pep8",
163 "deprecated form of raising exception"),
164 "W603": QCoreApplication.translate(
165 "pep8",
166 "'<>' is deprecated, use '!='"),
167 "W604": QCoreApplication.translate(
168 "pep8",
169 "backticks are deprecated, use 'repr()'"),
170 "E701": QCoreApplication.translate(
171 "pep8",
172 "multiple statements on one line (colon)"),
173 "E702": QCoreApplication.translate(
174 "pep8",
175 "multiple statements on one line (semicolon)"),
176 "E703": QCoreApplication.translate(
177 "pep8",
178 "statement ends with a semicolon"),
179 "E711": QCoreApplication.translate(
180 "pep8",
181 "comparison to {0} should be {1}"),
182 "E712": QCoreApplication.translate(
183 "pep8",
184 "comparison to {0} should be {1}"),
185 "E721": QCoreApplication.translate(
186 "pep8",
187 "do not compare types, use 'isinstance()'"),
188 "E901": QCoreApplication.translate(
189 "pep8",
190 "{0}: {1}"),
191
192 # DocStyleChecker messages
193 "D101": QCoreApplication.translate(
194 "DocStyleChecker", "module is missing a docstring"),
195 "D102": QCoreApplication.translate(
196 "DocStyleChecker",
197 "public function/method is missing a docstring"),
198 "D103": QCoreApplication.translate(
199 "DocStyleChecker",
200 "private function/method may be missing a docstring"),
201 "D104": QCoreApplication.translate(
202 "DocStyleChecker", "public class is missing a docstring"),
203 "D105": QCoreApplication.translate(
204 "DocStyleChecker", "private class may be missing a docstring"),
205 "D111": QCoreApplication.translate(
206 "DocStyleChecker", 'docstring not surrounded by """'),
207 "D112": QCoreApplication.translate(
208 "DocStyleChecker",
209 'docstring containing \\ not surrounded by r"""'),
210 "D113": QCoreApplication.translate(
211 "DocStyleChecker",
212 'docstring containing unicode character not surrounded by u"""'),
213 "D121": QCoreApplication.translate(
214 "DocStyleChecker", "one-liner docstring on multiple lines"),
215 "D122": QCoreApplication.translate(
216 "DocStyleChecker", "docstring has wrong indentation"),
217 "D131": QCoreApplication.translate(
218 "DocStyleChecker", "docstring summary does not end with a period"),
219 "D132": QCoreApplication.translate(
220 "DocStyleChecker",
221 "docstring summary is not in imperative mood"
222 " (Does instead of Do)"),
223 "D133": QCoreApplication.translate(
224 "DocStyleChecker",
225 "docstring summary looks like a function's/method's signature"),
226 "D134": QCoreApplication.translate(
227 "DocStyleChecker",
228 "docstring does not mention the return value type"),
229 "D141": QCoreApplication.translate(
230 "DocStyleChecker",
231 "function/method docstring is separated by a blank line"),
232 "D142": QCoreApplication.translate(
233 "DocStyleChecker",
234 "class docstring is not preceded by a blank line"),
235 "D143": QCoreApplication.translate(
236 "DocStyleChecker",
237 "class docstring is not followed by a blank line"),
238 "D144": QCoreApplication.translate(
239 "DocStyleChecker",
240 "docstring summary is not followed by a blank line"),
241 "D145": QCoreApplication.translate(
242 "DocStyleChecker",
243 "last paragraph of docstring is not followed by a blank line"),
244
245 "D203": QCoreApplication.translate(
246 "DocStyleChecker",
247 "private function/method is missing a docstring"),
248 "D205": QCoreApplication.translate(
249 "DocStyleChecker", "private class is missing a docstring"),
250 "D221": QCoreApplication.translate(
251 "DocStyleChecker",
252 "leading quotes of docstring not on separate line"),
253 "D222": QCoreApplication.translate(
254 "DocStyleChecker",
255 "trailing quotes of docstring not on separate line"),
256 "D231": QCoreApplication.translate(
257 "DocStyleChecker", "docstring summary does not end with a period"),
258 "D234": QCoreApplication.translate(
259 "DocStyleChecker",
260 "docstring does not contain a @return line but function/method"
261 " returns something"),
262 "D235": QCoreApplication.translate(
263 "DocStyleChecker",
264 "docstring contains a @return line but function/method doesn't"
265 " return anything"),
266 "D236": QCoreApplication.translate(
267 "DocStyleChecker",
268 "docstring does not contain enough @param/@keyparam lines"),
269 "D237": QCoreApplication.translate(
270 "DocStyleChecker",
271 "docstring contains too many @param/@keyparam lines"),
272 "D238": QCoreApplication.translate(
273 "DocStyleChecker",
274 "keyword only arguments must be documented with @keyparam lines"),
275 "D239": QCoreApplication.translate(
276 "DocStyleChecker", "order of @param/@keyparam lines does"
277 " not match the function/method signature"),
278 "D242": QCoreApplication.translate(
279 "DocStyleChecker", "class docstring is preceded by a blank line"),
280 "D243": QCoreApplication.translate(
281 "DocStyleChecker", "class docstring is followed by a blank line"),
282 "D244": QCoreApplication.translate(
283 "DocStyleChecker",
284 "function/method docstring is preceded by a blank line"),
285 "D245": QCoreApplication.translate(
286 "DocStyleChecker",
287 "function/method docstring is followed by a blank line"),
288 "D246": QCoreApplication.translate(
289 "DocStyleChecker",
290 "docstring summary is not followed by a blank line"),
291 "D247": QCoreApplication.translate(
292 "DocStyleChecker",
293 "last paragraph of docstring is followed by a blank line"),
294 "D250": QCoreApplication.translate(
295 "DocStyleChecker",
296 "docstring does not contain a @exception line but function/method"
297 " raises an exception"),
298 "D251": QCoreApplication.translate(
299 "DocStyleChecker",
300 "docstring contains a @exception line but function/method doesn't"
301 " raise an exception"),
302
303 "D901": QCoreApplication.translate(
304 "DocStyleChecker", "{0}: {1}"),
305
306 # NamingStyleChecker messages
307 "N801": QCoreApplication.translate(
308 "NamingStyleChecker",
309 "class names should use CapWords convention"),
310 "N802": QCoreApplication.translate(
311 "NamingStyleChecker",
312 "function name should be lowercase"),
313 "N803": QCoreApplication.translate(
314 "NamingStyleChecker",
315 "argument name should be lowercase"),
316 "N804": QCoreApplication.translate(
317 "NamingStyleChecker",
318 "first argument of a class method should be named 'cls'"),
319 "N805": QCoreApplication.translate(
320 "NamingStyleChecker",
321 "first argument of a method should be named 'self'"),
322 "N806": QCoreApplication.translate(
323 "NamingStyleChecker",
324 "first argument of a static method should not be named"
325 " 'self' or 'cls"),
326 "N807": QCoreApplication.translate(
327 "NamingStyleChecker",
328 "module names should be lowercase"),
329 "N808": QCoreApplication.translate(
330 "NamingStyleChecker",
331 "package names should be lowercase"),
332 "N811": QCoreApplication.translate(
333 "NamingStyleChecker",
334 "constant imported as non constant"),
335 "N812": QCoreApplication.translate(
336 "NamingStyleChecker",
337 "lowercase imported as non lowercase"),
338 "N813": QCoreApplication.translate(
339 "NamingStyleChecker",
340 "camelcase imported as lowercase"),
341 "N814": QCoreApplication.translate(
342 "NamingStyleChecker",
343 "camelcase imported as constant"),
344 "N821": QCoreApplication.translate(
345 "NamingStyleChecker",
346 "variable in function should be lowercase"),
347 "N831": QCoreApplication.translate(
348 "NamingStyleChecker",
349 "names 'l', 'O' and 'I' should be avoided"),
350
351 # CodeStyleFixer messages
352 "FD111": QCoreApplication.translate(
353 'CodeStyleFixer',
354 "Triple single quotes converted to triple double quotes."),
355 'FD112': QCoreApplication.translate(
356 'CodeStyleFixer',
357 'Introductory quotes corrected to be {0}"""'),
358 "FD121": QCoreApplication.translate(
359 'CodeStyleFixer',
360 "Single line docstring put on one line."),
361 "FD131": QCoreApplication.translate(
362 'CodeStyleFixer',
363 "Period added to summary line."),
364 "FD141": QCoreApplication.translate(
365 'CodeStyleFixer',
366 "Blank line before function/method docstring removed."),
367 "FD142": QCoreApplication.translate(
368 'CodeStyleFixer',
369 "Blank line inserted before class docstring."),
370 "FD143": QCoreApplication.translate(
371 'CodeStyleFixer',
372 "Blank line inserted after class docstring."),
373 "FD144": QCoreApplication.translate(
374 'CodeStyleFixer',
375 "Blank line inserted after docstring summary."),
376 "FD145": QCoreApplication.translate(
377 'CodeStyleFixer',
378 "Blank line inserted after last paragraph of docstring."),
379 "FD221": QCoreApplication.translate(
380 'CodeStyleFixer',
381 "Leading quotes put on separate line."),
382 "FD222": QCoreApplication.translate(
383 'CodeStyleFixer',
384 "Trailing quotes put on separate line."),
385 "FD242": QCoreApplication.translate(
386 'CodeStyleFixer',
387 "Blank line before class docstring removed."),
388 "FD244": QCoreApplication.translate(
389 'CodeStyleFixer',
390 "Blank line before function/method docstring removed."),
391 "FD243": QCoreApplication.translate(
392 'CodeStyleFixer',
393 "Blank line after class docstring removed."),
394 "FD245": QCoreApplication.translate(
395 'CodeStyleFixer',
396 "Blank line after function/method docstring removed."),
397 "FD247": QCoreApplication.translate(
398 'CodeStyleFixer',
399 "Blank line after last paragraph removed."),
400 "FE101": QCoreApplication.translate(
401 'CodeStyleFixer',
402 "Tab converted to 4 spaces."),
403 "FE111": QCoreApplication.translate(
404 'CodeStyleFixer',
405 "Indentation adjusted to be a multiple of four."),
406 "FE121": QCoreApplication.translate(
407 'CodeStyleFixer',
408 "Indentation of continuation line corrected."),
409 "FE124": QCoreApplication.translate(
410 'CodeStyleFixer',
411 "Indentation of closing bracket corrected."),
412 "FE122": QCoreApplication.translate(
413 'CodeStyleFixer',
414 "Missing indentation of continuation line corrected."),
415 "FE123": QCoreApplication.translate(
416 'CodeStyleFixer',
417 "Closing bracket aligned to opening bracket."),
418 "FE125": QCoreApplication.translate(
419 'CodeStyleFixer',
420 "Indentation level changed."),
421 "FE126": QCoreApplication.translate(
422 'CodeStyleFixer',
423 "Indentation level of hanging indentation changed."),
424 "FE127": QCoreApplication.translate(
425 'CodeStyleFixer',
426 "Visual indentation corrected."),
427 "FE201": QCoreApplication.translate(
428 'CodeStyleFixer',
429 "Extraneous whitespace removed."),
430 "FE225": QCoreApplication.translate(
431 'CodeStyleFixer',
432 "Missing whitespace added."),
433 "FE221": QCoreApplication.translate(
434 'CodeStyleFixer',
435 "Extraneous whitespace removed."),
436 "FE231": QCoreApplication.translate(
437 'CodeStyleFixer',
438 "Missing whitespace added."),
439 "FE251": QCoreApplication.translate(
440 'CodeStyleFixer',
441 "Extraneous whitespace removed."),
442 "FE261": QCoreApplication.translate(
443 'CodeStyleFixer',
444 "Whitespace around comment sign corrected."),
445 "FE301": QCoreApplication.translate(
446 'CodeStyleFixer',
447 "One blank line inserted."),
448
449 "FE302+": lambda n=1: QCoreApplication.translate(
450 'CodeStyleFixer',
451 "%n blank line(s) inserted.", '', QCoreApplication.CodecForTr, n),
452 "FE302-": lambda n=1: QCoreApplication.translate(
453 'CodeStyleFixer',
454 "%n superfluous lines removed", '', QCoreApplication.CodecForTr, n),
455
456 "FE303": QCoreApplication.translate(
457 'CodeStyleFixer',
458 "Superfluous blank lines removed."),
459 "FE304": QCoreApplication.translate(
460 'CodeStyleFixer',
461 "Superfluous blank lines after function decorator removed."),
462 "FE401": QCoreApplication.translate(
463 'CodeStyleFixer',
464 "Imports were put on separate lines."),
465 "FE501": QCoreApplication.translate(
466 'CodeStyleFixer',
467 "Long lines have been shortened."),
468 "FE502": QCoreApplication.translate(
469 'CodeStyleFixer',
470 "Redundant backslash in brackets removed."),
471 "FE701": QCoreApplication.translate(
472 'CodeStyleFixer',
473 "Compound statement corrected."),
474 "FE702": QCoreApplication.translate(
475 'CodeStyleFixer',
476 "Compound statement corrected."),
477 "FE711": QCoreApplication.translate(
478 'CodeStyleFixer',
479 "Comparison to None/True/False corrected."),
480 "FN804": QCoreApplication.translate(
481 'CodeStyleFixer',
482 "'{0}' argument added."),
483 "FN806": QCoreApplication.translate(
484 'CodeStyleFixer',
485 "'{0}' argument removed."),
486 "FW291": QCoreApplication.translate(
487 'CodeStyleFixer',
488 "Whitespace stripped from end of line."),
489 "FW292": QCoreApplication.translate(
490 'CodeStyleFixer',
491 "newline added to end of file."),
492 "FW391": QCoreApplication.translate(
493 'CodeStyleFixer',
494 "Superfluous trailing blank lines removed from end of file."),
495 "FW603": QCoreApplication.translate(
496 'CodeStyleFixer',
497 "'<>' replaced by '!='."),
498
499 "FWRITE_ERROR": QCoreApplication.translate(
500 'CodeStyleFixer',
501 "Could not save the file! Skipping it. Reason: {0}"),
502 }
503
504
505 def getTranslatedMessage(message):
506 """
507 Module function to get a translated and formatted message for a
508 given pyflakes message ID.
509
510 @param message the message ID (string)
511 @return translated and formatted message (string)
512 """
513 if isinstance(message, list):
514 message, args = message
515 else:
516 args = []
517 if message in _messages:
518 if isinstance(args, int):
519 # Retranslate with correct plural form
520 return _messages[message](args)
521 else:
522 if message.startswith('F'):
523 prefix = ''
524 else:
525 prefix = message + ' '
526 return prefix + _messages[message].format(*args)
527 elif ' ' in message:
528 # already translated
529 return message
530 else:
531 return QCoreApplication.translate(
532 "CodeStyleFixer", " no message defined for code '{0}'")\
533 .format(message)

eric ide

mercurial