Commit 2c930ad5 authored by Michal Čihař's avatar Michal Čihař

Allow to override translation unit behaviour based on format

Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent c98473f5
...@@ -353,6 +353,7 @@ class FileFormat(object): ...@@ -353,6 +353,7 @@ class FileFormat(object):
loader = (None, None) loader = (None, None)
monolingual = None monolingual = None
check_flags = () check_flags = ()
unit_class = FileUnit
@classmethod @classmethod
def fixup(cls, store): def fixup(cls, store):
...@@ -454,7 +455,7 @@ class FileFormat(object): ...@@ -454,7 +455,7 @@ class FileFormat(object):
else: else:
add = False add = False
return (FileUnit(ttkit_unit, template_ttkit_unit), add) return (self.unit_class(ttkit_unit, template_ttkit_unit), add)
def _find_unit_bilingual(self, context, source): def _find_unit_bilingual(self, context, source):
# Find all units with same source # Find all units with same source
...@@ -474,11 +475,11 @@ class FileFormat(object): ...@@ -474,11 +475,11 @@ class FileFormat(object):
ttkit_unit_context = ttkit_unit.getcontext() ttkit_unit_context = ttkit_unit.getcontext()
# Does context match? # Does context match?
if ttkit_unit_context == context: if ttkit_unit_context == context:
return (FileUnit(ttkit_unit), False) return (self.unit_class(ttkit_unit), False)
else: else:
# Fallback to manual find for value based files # Fallback to manual find for value based files
for ttkit_unit in self.store.units: for ttkit_unit in self.store.units:
ttkit_unit = FileUnit(ttkit_unit) ttkit_unit = self.unit_class(ttkit_unit)
if ttkit_unit.get_source() == source: if ttkit_unit.get_source() == source:
return (ttkit_unit, False) return (ttkit_unit, False)
return (None, False) return (None, False)
...@@ -537,12 +538,12 @@ class FileFormat(object): ...@@ -537,12 +538,12 @@ class FileFormat(object):
for tt_unit in self.store.units: for tt_unit in self.store.units:
# Create wrapper object # Create wrapper object
yield FileUnit(tt_unit) yield self.unit_class(tt_unit)
else: else:
for template_unit in self.template_store.units: for template_unit in self.template_store.units:
# Create wrapper object (not translated) # Create wrapper object (not translated)
yield FileUnit( yield self.unit_class(
self.store.findid(template_unit.getid()), self.store.findid(template_unit.getid()),
template_unit template_unit
) )
......
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