~chromium-team/chromium-browser/chromium-translations-tools.head

« back to all changes in this revision

Viewing changes to chromium2pot.py

  • Committer: Fabien Tassin
  • Date: 2011-05-25 14:42:59 UTC
  • Revision ID: fta@ubuntu.com-20110525144259-s7z6cnm7dfdz3eod
* Keep dropping the heading and trailing \n from translations when they
  don't match the string to translate. Some translators seem to like
  adding several trailing \n

Show diffs side-by-side

added added

removed removed

Lines of Context:
1224
1224
 
1225
1225
  def add_translation(self, id, string):
1226
1226
    assert id in self.template.supported_ids, "'%s' is not in supported_ids (file=%s)" % (id, self.filename)
1227
 
    if string[-1:] == '\n' and self.template.supported_ids[id]['ids'][0]['val'][-1:] != '\n':
 
1227
    while string[-1:] == '\n' and self.template.supported_ids[id]['ids'][0]['val'][-1:] != '\n':
1228
1228
      # prevent the `msgid' and `msgstr' entries do not both end with '\n' error
1229
1229
      if self.debug:
1230
1230
        print "Found unwanted \\n at the end of translation id " + id + " lang " + self.lang + ". Dropped"
1231
1231
      string = string[:-1]
1232
 
    if string[0] == '\n' and self.template.supported_ids[id]['ids'][0]['val'][0] != '\n':
 
1232
    while string[0] == '\n' and self.template.supported_ids[id]['ids'][0]['val'][0] != '\n':
1233
1233
      # prevent the `msgid' and `msgstr' entries do not both begin with '\n' error
1234
1234
      if self.debug:
1235
1235
        print "Found unwanted \\n at the begin of translation id " + id + " lang " + self.lang + ". Dropped"