예제 #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
     )