diff -r 7f4f864f4e20 webtranslate/newgrf/language_file.py
--- a/webtranslate/newgrf/language_file.py Tue May 26 21:59:05 2015 +0200
+++ b/webtranslate/newgrf/language_file.py Wed May 27 19:11:47 2015 +0200
@@ -420,7 +420,7 @@
@type plurals: C{list} of C{int}
@ivar commands: String commands at each position.
- @type commands: C{list} of C{ParameterInfo}
+ @type commands: C{list} of (L{ParameterInfo} or C{None})
@ivar non_positionals: Mapping of commands without position to their count.
@type non_positionals: C{dict} of C{str} to C{int}
@@ -612,10 +612,6 @@
Check sanity of the string commands and parameters.
"""
ok = True
- for pos, cmd in enumerate(self.commands):
- if cmd is None:
- self.add_error(ErrorMessage(ERROR, None, "String parameter {} has no string command".format(pos)))
- ok = False
if ok:
for pos in self.plurals:
if pos < 0 or pos >= len(self.commands):
@@ -964,8 +960,8 @@
if base_info.has_error: return True # Cannot blame the translation when the base language is broken.
if lng_info.has_error: return False # Translation has more serious problems.
- base_cmds = [cmd.get_translated_cmd() for cmd in base_info.commands]
- lng_cmds = [cmd.literal for cmd in lng_info.commands]
+ base_cmds = [(cmd.get_translated_cmd() if cmd is not None else None) for cmd in base_info.commands]
+ lng_cmds = [(cmd.literal if cmd is not None else None) for cmd in lng_info.commands]
if base_cmds != lng_cmds:
if len(base_cmds) > len(lng_cmds):
@@ -981,8 +977,15 @@
for i in range(len(base_cmds)):
if base_cmds[i] != lng_cmds[i]:
- msg = 'String command for position {} is wrong, base language uses {}, the translation uses {}'
- msg = msg.format(i, '{' + base_cmds[i] + '}', '{' + lng_cmds[i] + '}')
+ if base_cmds[i] is None:
+ msg = 'String command for position {} does not exist, the translation uses {}'
+ msg = msg.format(i, '{' + lng_cmds[i] + '}')
+ elif lng_cmds[i] is None:
+ msg = 'String command for position {} ({}) is missing in translation'
+ msg = msg.format(i, '{' + base_cmds[i] + '}')
+ else:
+ msg = 'String command for position {} is wrong, base language uses {}, the translation uses {}'
+ msg = msg.format(i, '{' + base_cmds[i] + '}', '{' + lng_cmds[i] + '}')
lng_info.add_error(ErrorMessage(ERROR, None, msg))
return False