Loading

Paste #pvqtvtuku

  1. diff -r 7f4f864f4e20 webtranslate/newgrf/language_file.py
  2. --- a/webtranslate/newgrf/language_file.py  Tue May 26 21:59:05 2015 +0200
  3. +++ b/webtranslate/newgrf/language_file.py  Wed May 27 19:11:47 2015 +0200
  4. @@ -420,7 +420,7 @@
  5.      @type plurals: C{list} of C{int}
  6.  
  7.      @ivar commands: String commands at each position.
  8. -    @type commands: C{list} of C{ParameterInfo}
  9. +    @type commands: C{list} of (L{ParameterInfo} or C{None})
  10.  
  11.      @ivar non_positionals: Mapping of commands without position to their count.
  12.      @type non_positionals: C{dict} of C{str} to C{int}
  13. @@ -612,10 +612,6 @@
  14.          Check sanity of the string commands and parameters.
  15.          """
  16.          ok = True
  17. -        for pos, cmd in enumerate(self.commands):
  18. -            if cmd is None:
  19. -                self.add_error(ErrorMessage(ERROR, None, "String parameter {} has no string command".format(pos)))
  20. -                ok = False
  21.          if ok:
  22.              for pos in self.plurals:
  23.                  if pos < 0 or pos >= len(self.commands):
  24. @@ -964,8 +960,8 @@
  25.      if base_info.has_error: return True # Cannot blame the translation when the base language is broken.
  26.      if lng_info.has_error: return False # Translation has more serious problems.
  27.  
  28. -    base_cmds = [cmd.get_translated_cmd() for cmd in base_info.commands]
  29. -    lng_cmds = [cmd.literal for cmd in lng_info.commands]
  30. +    base_cmds = [(cmd.get_translated_cmd() if cmd is not None else None) for cmd in base_info.commands]
  31. +    lng_cmds = [(cmd.literal if cmd is not None else None) for cmd in lng_info.commands]
  32.  
  33.      if base_cmds != lng_cmds:
  34.          if len(base_cmds) > len(lng_cmds):
  35. @@ -981,8 +977,15 @@
  36.  
  37.          for i in range(len(base_cmds)):
  38.              if base_cmds[i] != lng_cmds[i]:
  39. -                msg = 'String command for position {} is wrong, base language uses {}, the translation uses {}'
  40. -                msg = msg.format(i, '{' + base_cmds[i] + '}', '{' + lng_cmds[i] + '}')
  41. +                if base_cmds[i] is None:
  42. +                    msg = 'String command for position {} does not exist, the translation uses {}'
  43. +                    msg = msg.format(i, '{' + lng_cmds[i] + '}')
  44. +                elif lng_cmds[i] is None:
  45. +                    msg = 'String command for position {} ({}) is missing in translation'
  46. +                    msg = msg.format(i, '{' + base_cmds[i] + '}')
  47. +                else:
  48. +                    msg = 'String command for position {} is wrong, base language uses {}, the translation uses {}'
  49. +                    msg = msg.format(i, '{' + base_cmds[i] + '}', '{' + lng_cmds[i] + '}')
  50.                  lng_info.add_error(ErrorMessage(ERROR, None, msg))
  51.                  return False
  52.  
  53.  

Comments