def get_source(self): ''' Returns source string from a ttkit unit. ''' if self.is_unit_key_value(): # Need to decode property encoded string if isinstance(self.unit, propunit): return quote.propertiesdecode(self.mainunit.name) return self.mainunit.name else: if self.template is not None: return get_string(self.template.target) else: return get_string(self.unit.source)
def get_previous_source(self): ''' Returns previous message source if there was any. ''' if not self.is_fuzzy() or not hasattr(self.unit, 'prev_source'): return '' return get_string(self.unit.prev_source)
def get_target(self): ''' Returns target string from a ttkit unit. ''' if self.unit is None: return '' if self.is_unit_key_value(): # Need to decode property encoded string if isinstance(self.unit, propunit): # This is basically stolen from # translate.storage.properties.propunit.gettarget # which for some reason does not return translation value = quote.propertiesdecode(self.unit.value) value = re.sub(u"\\\\ ", u" ", value) return value return self.unit.value else: return get_string(self.unit.target)