示例#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)
示例#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)
示例#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 "
示例#4
0
 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 "
示例#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)
示例#6
0
文件: base.py 项目: daleathan/weblate
 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)
示例#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
示例#8
0
文件: ttkit.py 项目: nijel/weblate
 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
示例#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\\"
示例#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\\"
示例#11
0
文件: base.py 项目: daleathan/weblate
 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)
示例#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)
示例#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
示例#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)
示例#15
0
文件: util.py 项目: lohrun/weblate
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
示例#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)
示例#17
0
 def gettarget(self):
     return re.sub(u"\\\\ ", u" ", quote.propertiesdecode(self.translation))
示例#18
0
 def gettarget(self):
     translation = quote.propertiesdecode(self.translation)
     translation = re.sub(u"\\\\ ", u" ", translation)
     return translation
示例#19
0
 def getsource(self):
     value = quote.propertiesdecode(self.value)
     return value
示例#20
0
 def decode(cls, string):
     return quote.propertiesdecode(string)
示例#21
0
 def getsource(self):
     value = quote.propertiesdecode(self.value)
     value = re.sub(u"\\\\ ", u" ", value)
     return value
示例#22
0
 def getsource(self):
     return quote.propertiesdecode(self.value)
示例#23
0
文件: test_quote.py 项目: Osmose/kuma
 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 "
示例#24
0
 def gettarget(self):
     translation = quote.propertiesdecode(self.translation)
     translation = re.sub(u"\\\\ ", u" ", translation)
     return translation
示例#25
0
 def getsource(self):
     value = quote.propertiesdecode(self.value)
     return value
示例#26
0
 def decode(string):
     return quote.propertiesdecode(string)
示例#27
0
 def source(self):
     # Need to decode property encoded string
     return quote.propertiesdecode(super(PropertiesUnit, self).source)
示例#28
0
 def getsource(self):
     value = quote.propertiesdecode(self.value)
     value = re.sub(u"\\\\ ", u" ", value)
     return value
示例#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 "
示例#30
0
文件: ttkit.py 项目: nijel/weblate
 def source(self):
     # Need to decode property encoded string
     return quote.propertiesdecode(
         super(PropertiesUnit, self).source
     )