Beispiel #1
0
 def get_source(self):
     '''
     Returns source string from a ttkit unit.
     '''
     if (isinstance(self.mainunit, tsunit) and
             self.template is None and
             self.mainunit.hasplural()):
         # Need to apply special magic for plurals here
         # as there is no singlular/plural in the source string
         return join_plural([
             self.unit.source,
             self.unit.source,
         ])
     if self.is_unit_key_value():
         # Need to decode property encoded string
         if isinstance(self.mainunit, propunit):
             if self.template is not None:
                 return quote.propertiesdecode(self.template.value)
             else:
                 return quote.propertiesdecode(self.unit.name)
         if self.template is not None:
             return self.template.value
         else:
             return self.unit.name
     else:
         if self.template is not None:
             return get_string(self.template.target)
         else:
             return get_string(self.unit.source)
Beispiel #2
0
 def get_source(self):
     '''
     Returns source string from a ttkit unit.
     '''
     if (isinstance(self.mainunit, tsunit) and
             self.template is None and
             self.mainunit.hasplural()):
         # Need to apply special magic for plurals here
         # as there is no singlular/plural in the source string
         return join_plural([
             self.unit.source,
             self.unit.source,
         ])
     if self.is_unit_key_value():
         # Need to decode property encoded string
         if isinstance(self.mainunit, propunit):
             if self.template is not None:
                 return quote.propertiesdecode(self.template.value)
             else:
                 return quote.propertiesdecode(self.unit.name)
         if self.template is not None:
             return self.template.value
         else:
             return self.unit.name
     else:
         if self.template is not None:
             return get_string(self.template.target)
         else:
             return get_string(self.unit.source)
Beispiel #3
0
 def test_properties_decode_slashu():
     # The real input strings don't have double backslashes, but we have to
     # double them here because Python immediately decode them, even for raw
     # strings.
     assert quote.propertiesdecode("abc\\u1e13") == "abcḓ"
     assert quote.propertiesdecode("abc\\u0020") == "abc "
     # NOTE Java only accepts 4 digit unicode, Mozilla accepts two
     # unfortunately, but it seems harmless to accept both.
     assert quote.propertiesdecode("abc\\u20") == "abc "
 def test_properties_decode_slashu(self):
     # The real input strings don't have double backslashes, but we have to
     # double them here because Python immediately decode them, even for raw
     # strings.
     assert quote.propertiesdecode(u"abc\\u1e13") == u"abcḓ"
     assert quote.propertiesdecode(u"abc\\u0020") == u"abc "
     # NOTE Java only accepts 4 digit unicode, Mozilla accepts two
     # unfortunately, but it seems harmless to accept both.
     assert quote.propertiesdecode("abc\\u20") == u"abc "
Beispiel #5
0
 def get_source(self):
     """Return source string from a ttkit unit."""
     if self.is_unit_key_value(self.mainunit):
         # Need to decode property encoded string
         if isinstance(self.mainunit, propunit):
             if self.template is not None:
                 return quote.propertiesdecode(self.template.value)
             return quote.propertiesdecode(self.unit.name)
         if self.template is not None:
             return self.template.value
         return self.unit.name
     else:
         if self.template is not None:
             return get_string(self.template.target)
         return get_string(self.unit.source)
Beispiel #6
0
 def get_source(self):
     """Return source string from a ttkit unit."""
     if self.is_unit_key_value(self.mainunit):
         # Need to decode property encoded string
         if isinstance(self.mainunit, propunit):
             if self.template is not None:
                 return quote.propertiesdecode(self.template.value)
             return quote.propertiesdecode(self.unit.name)
         if self.template is not None:
             return self.template.value
         return self.unit.name
     else:
         if self.template is not None:
             return get_string(self.template.target)
         return get_string(self.unit.source)
Beispiel #7
0
 def target(self):
     """Return target string from a ttkit unit."""
     if self.unit is None:
         return ''
     # Need to decode property encoded string
     # 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('\\\\ ', ' ', value)
     return value
Beispiel #8
0
 def target(self):
     """Return target string from a ttkit unit."""
     if self.unit is None:
         return ''
     # Need to decode property encoded string
     # 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('\\\\ ', ' ', value)
     return value
Beispiel #9
0
 def test_propertiesdecode():
     assert quote.propertiesdecode("abc") == "abc"
     assert quote.propertiesdecode("abc\\u1e13") == "abcḓ"
     assert quote.propertiesdecode("abc\\u1E13") == "abcḓ"
     assert quote.propertiesdecode("abc\N{LEFT CURLY BRACKET}") == "abc{"
     assert quote.propertiesdecode("abc\\") == "abc\\"
     assert quote.propertiesdecode("abc\\") == "abc\\"
Beispiel #10
0
 def test_propertiesdecode(self):
     assert quote.propertiesdecode(u"abc") == u"abc"
     assert quote.propertiesdecode(u"abc\\u1e13") == u"abcḓ"
     assert quote.propertiesdecode(u"abc\\u1E13") == u"abcḓ"
     assert quote.propertiesdecode(u"abc\N{LEFT CURLY BRACKET}") == u"abc{"
     assert quote.propertiesdecode(u"abc\\") == u"abc\\"
     assert quote.propertiesdecode(u"abc\\") == u"abc\\"
Beispiel #11
0
 def get_target(self):
     """Return target string from a ttkit unit."""
     if self.unit is None:
         return ''
     if self.is_unit_key_value(self.unit):
         # 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('\\\\ ', ' ', value)
             return value
         return self.unit.value
     return get_string(self.unit.target)
Beispiel #12
0
 def get_target(self):
     """Return target string from a ttkit unit."""
     if self.unit is None:
         return ''
     if self.is_unit_key_value(self.unit):
         # 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('\\\\ ', ' ', value)
             return value
         return self.unit.value
     return get_string(self.unit.target)
Beispiel #13
0
def get_target(unit):
    '''
    Returns target string from a ttkit unit.
    '''
    if unit is None:
        return ''
    if is_unit_key_value(unit):
        # Need to decode property encoded string
        if isinstance(unit, propunit):
            # This is basically stolen from
            # translate.storage.properties.propunit.gettarget
            # which for some reason does not return translation
            value = quote.propertiesdecode(unit.value)
            value = re.sub(u"\\\\ ", u" ", value)
            return value
        return unit.value
    else:
        if hasattr(unit.target, 'strings'):
            return join_plural(unit.target.strings)
        else:
            return unit.target
Beispiel #14
0
 def get_target(self):
     """
     Returns target string from a ttkit unit.
     """
     if self.unit is None:
         return ""
     if isinstance(self.unit, tsunit) and not self.unit.isreview() and not self.unit.istranslated():
         # For Qt ts, empty translated string means source should be used
         return self.get_source()
     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)
Beispiel #15
0
def get_target(unit):
    '''
    Returns target string from a ttkit unit.
    '''
    if unit is None:
        return ''
    if is_unit_key_value(unit):
        # Need to decode property encoded string
        if isinstance(unit, propunit):
            # This is basically stolen from
            # translate.storage.properties.propunit.gettarget
            # which for some reason does not return translation
            value = quote.propertiesdecode(unit.value)
            value = re.sub(u"\\\\ ", u" ", value)
            return value
        return unit.value
    else:
        if hasattr(unit.target, 'strings'):
            return join_plural(unit.target.strings)
        else:
            return unit.target
Beispiel #16
0
 def get_target(self):
     '''
     Returns target string from a ttkit unit.
     '''
     if self.unit is None:
         return ''
     if (isinstance(self.unit, tsunit) and not self.unit.isreview()
             and not self.unit.istranslated()):
         # For Qt ts, empty translated string means source should be used
         return self.get_source()
     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)
Beispiel #17
0
 def gettarget(self):
     return re.sub(u"\\\\ ", u" ", quote.propertiesdecode(self.translation))
Beispiel #18
0
 def gettarget(self):
     translation = quote.propertiesdecode(self.translation)
     translation = re.sub(u"\\\\ ", u" ", translation)
     return translation
Beispiel #19
0
 def getsource(self):
     value = quote.propertiesdecode(self.value)
     return value
Beispiel #20
0
 def decode(cls, string):
     return quote.propertiesdecode(string)
Beispiel #21
0
 def getsource(self):
     value = quote.propertiesdecode(self.value)
     value = re.sub(u"\\\\ ", u" ", value)
     return value
Beispiel #22
0
 def getsource(self):
     return quote.propertiesdecode(self.value)
Beispiel #23
0
 def test_properties_decode_slashu(self):
     assert quote.propertiesdecode(u"abc\u1e13") == u"abcḓ"
     assert quote.propertiesdecode(u"abc\u0020") == u"abc "
     # NOTE Java only accepts 4 digit unicode, Mozilla accepts two
     # unfortunately, but it seems harmless to accept both.
     assert quote.propertiesdecode("abc\u20") == u"abc "
Beispiel #24
0
 def gettarget(self):
     translation = quote.propertiesdecode(self.translation)
     translation = re.sub(u"\\\\ ", u" ", translation)
     return translation
Beispiel #25
0
 def getsource(self):
     value = quote.propertiesdecode(self.value)
     return value
Beispiel #26
0
 def decode(string):
     return quote.propertiesdecode(string)
Beispiel #27
0
 def source(self):
     # Need to decode property encoded string
     return quote.propertiesdecode(super(PropertiesUnit, self).source)
Beispiel #28
0
 def getsource(self):
     value = quote.propertiesdecode(self.value)
     value = re.sub(u"\\\\ ", u" ", value)
     return value
Beispiel #29
0
 def test_properties_decode_slashu(self):
     assert quote.propertiesdecode(u"abc\u1e13") == u"abcḓ"
     assert quote.propertiesdecode(u"abc\u0020") == u"abc "
     # NOTE Java only accepts 4 digit unicode, Mozilla accepts two
     # unfortunately, but it seems harmless to accept both.
     assert quote.propertiesdecode("abc\u20") == u"abc "
Beispiel #30
0
 def source(self):
     # Need to decode property encoded string
     return quote.propertiesdecode(
         super(PropertiesUnit, self).source
     )