Commit b7bd4960 authored by Michal Čihař's avatar Michal Čihař

Handle situation when backend did not find the message (issue #43)

parent 77f0cf38
......@@ -841,10 +841,12 @@ class Translation(models.Model):
store = self.get_store()
src = unit.get_source_plurals()[0]
need_save = False
found = False
# Find all units with same source
for pounit in store.findunits(src):
# Does context match?
if pounit.getcontext() == unit.context:
found = True
# Is it plural?
if hasattr(pounit.target, 'strings'):
potarget = join_plural(pounit.target.strings)
......@@ -864,6 +866,9 @@ class Translation(models.Model):
# We should have only one match
break
if not found:
return False, None
# Save backend if there was a change
if need_save:
author = self.get_author_name(request.user)
......@@ -1079,6 +1084,11 @@ class Unit(models.Model):
# Store to backend
(saved, pounit) = self.translation.update_unit(self, request)
# Handle situation when backend did not find the message
if pounit is None:
logger.error('message %s disappeared!', self)
messages.error(request, _('Message not found in backend storage, it is probably corrupted.'))
# Update translated flag
self.translated = pounit.istranslated()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment