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

Simplify XLIFF context handling

We should use the full ID to avoid possible problems with namespaced
translations.

Issue #939
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent ac251a4d
...@@ -24,7 +24,8 @@ from django.utils.translation import ugettext_lazy as _ ...@@ -24,7 +24,8 @@ from django.utils.translation import ugettext_lazy as _
from translate.convert import po2php from translate.convert import po2php
from translate.storage.lisa import LISAfile from translate.storage.lisa import LISAfile
from translate.storage.properties import propunit, propfile from translate.storage.properties import propunit, propfile
from translate.storage.xliff import xliffunit, xlifffile from translate.storage.xliff import xliffunit, xlifffile, ID_SEPARATOR
from translate.storage.po import pounit, pofile from translate.storage.po import pounit, pofile
from translate.storage.php import phpunit from translate.storage.php import phpunit
from translate.storage.ts2 import tsunit, tsfile from translate.storage.ts2 import tsunit, tsfile
...@@ -348,11 +349,7 @@ class XliffUnit(FileUnit): ...@@ -348,11 +349,7 @@ class XliffUnit(FileUnit):
Returns context of message. In some cases we have to use Returns context of message. In some cases we have to use
ID here to make all backends consistent. ID here to make all backends consistent.
''' '''
context = self.mainunit.getlocations() return self.mainunit.getid().replace(ID_SEPARATOR, '///')
if len(context) == 0:
return ''
else:
return context[0]
def get_locations(self): def get_locations(self):
''' '''
...@@ -966,13 +963,10 @@ class XliffFormat(FileFormat): ...@@ -966,13 +963,10 @@ class XliffFormat(FileFormat):
content.savefile(filename) content.savefile(filename)
def _find_unit_mono(self, context, store): def _find_unit_mono(self, context, store):
# Do not use findid as it does not work for empty translations return super(self, XliffFormat)._find_unit_mono(
for search_unit in self.store.units: context.replace('///', ID_SEPARATOR),
loc = search_unit.getlocations() store
if len(loc) > 0: )
loc = loc[0]
if loc == context:
return search_unit
@register_fileformat @register_fileformat
......
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