Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore no longer existing translations. #7

Merged
merged 1 commit into from
Apr 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
1.2.3 (unreleased)
------------------

- Nothing changed yet.
- Ignore no longer existing translations.
[phgross]


1.2.2 (2015-03-13)
Expand Down
6 changes: 6 additions & 0 deletions ftw/recipe/translations/tests/test_masstranslate_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ def test_download(self):
'id': u'label_login',
'default': u'Login',
'translations': {u'de': u'Anmelden'},
},
{'package': u'foo',
'domain': u'bar',
'id': u'this_was_removed',
'default': u'Yay',
'translations': {u'de': u'Yay'},
}]})
download.download(spreadsheet, self.tempdir,
worksheet_name='worksheet',
Expand Down
7 changes: 6 additions & 1 deletion ftw/recipe/translations/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ def write_catalog(sources_directory, catalog):
for message in catalog.messages:
for language, msgstr in message.translations.items():
pofile = registry.find_pofile_for(message, language)
pofile.get(message.msgid).msgstr = msgstr
target_message = pofile.get(message.msgid)
if target_message is None:
print ('Warning: Ignoring "{0}" of "{1}" because it does no'
' longer exist.'.format(message.msgid, message.domain))
continue
target_message.msgstr = msgstr

registry.write_pofiles()

Expand Down