Logo Search packages:      
Sourcecode: zope-cps-translationservice version File versions  Download package

def TranslationService::Domain::Domain::_interpolate (   self,
) [private]

Interpolate ${keyword} substitutions.

Definition at line 109 of file Domain.py.

00109                                          :
        """Interpolate ${keyword} substitutions."""
        if not mapping:
            return text

        # Find all the spots we want to substitute.
        to_replace = _interp_regex.findall(text)

        # Now substitute with the variables in mapping.
        encoding = None
        for string in to_replace:
            var = _get_var_regex.findall(string)[0]
            if mapping.has_key(var):
                subst = ustr(mapping[var])
                    text = text.replace(string, subst)
                except UnicodeError:
                    # The string subst contains high-bit chars.
                    # Assume it's encoded in the output encoding.
                    # (This will be the case if Localizer was used.)
                    if encoding is None:
                        encoding = _findEncoding()
                    subst = unicode(subst, encoding, 'ignore')
                    text = text.replace(string, subst)

        return text

class DummyDomain(Domain):

Generated by  Doxygen 1.6.0   Back to index