Transliterate the string to the target language.
498639
def transliterate(self, target_language="en"):
    """"""
    return WordList([w.transliterate(target_language) for w in self.words],
                     language=target_language, parent=self)
123014
def slugify(mapping, bind, values):
    
    for value in values:
        if isinstance(value, six.string_types):
            value = transliterate(value)
            value = normality.slugify(value)
        yield value
37187
public String normalize(String input, Language language) {
      if (input == null) {
         return null;
      }
      String finalString = input;
      for (TextNormalizer textNormalizer : preprocessors) {
         finalString = textNormalizer.apply(finalString, language);
      }
      return finalString;
   }
604801
def slugify(value, separator="-"):
    """"""
    if not isinstance(value, str):
        raise ValueError("value must be a Unicode string")
    value = _NOT_WORD_RE.sub(" ", value)
    value = unicodedata.normalize("NFKD", value)
    value = value.encode("ascii", "ignore")
    value = value.decode("ascii")
    value = value.strip().lower()
    value = re.sub(fr"[{separator}_\s]+", separator, value)
    return value
813924
def translate_escaped_str(cls, str_val):
        """"""
        if isinstance(str_val, string_types):
            str_val = str_val.encode('unicode_escape')
            if sys.version_info >= (3, 0):
                str_val = str_val.decode('utf-8')
            str_val = str_val.replace('"', r'\"')
        return '"{}"'.format(str_val)
938386
def trans_search(encoding):
    """"""
    if encoding == 'transliterate':
        return codecs.CodecInfo(long_encode, no_decode)

    # translit/long/utf8
    # translit/one
    # translit/short/ascii

    if encoding.startswith('translit/'):
        parts = encoding.split('/')
        if parts[1] == 'long':
            encoder = long_encode
        elif parts[1] == 'short':
            encoder = short_encode
        elif parts[1] == 'one':
            encoder = single_encode
        else:
            return None

        if len(parts) == 2:
            pass
        elif len(parts) == 3:
            byte_enc = parts[2]
            byte_encoder = codecs.lookup(byte_enc).encode
            encoder = _double_encoding_factory(encoder, byte_encoder, byte_enc)
        else:
            return None
        return codecs.CodecInfo(encoder, no_decode)
    return None
1048234
def to_python(self, value, resource):
        """"""

        if value is None:
            return self._transform(value)

        if isinstance(value, six.text_type):
            return self._transform(value)

        if self.encoding is None and isinstance(value, (six.text_type, six.binary_type)):
            return self._transform(value)

        if self.encoding is not None and isinstance(value, six.binary_type):
            return self._transform(value.decode(self.encoding))

        return self._transform(six.text_type(value))
1083724
def translate(cls, val):
        """"""
        if val is None:
            return cls.translate_none(val)
        elif isinstance(val, string_types):
            return cls.translate_str(val)
        # Needs to be before integer checks
        elif isinstance(val, bool):
            return cls.translate_bool(val)
        elif isinstance(val, integer_types):
            return cls.translate_int(val)
        elif isinstance(val, float):
            return cls.translate_float(val)
        elif isinstance(val, dict):
            return cls.translate_dict(val)
        elif isinstance(val, list):
            return cls.translate_list(val)
        # Use this generic translation as a last resort
        return cls.translate_escaped_str(val)
65368
def utf(text):
    """"""
    try:
        output = unicode(text, encoding='utf-8')
    except UnicodeDecodeError:
        output = text
    except TypeError:
        output = text
    return output
1102719
def process_input(self, paragraph):
        """"""
        try:
            lang, body = paragraph.split(None, 1)
        except ValueError:
            lang, body = paragraph, None

        if not lang.strip().startswith('%'):
            lang = 'scala'
            body = paragraph.strip()

        else:
            lang = lang.strip()[1:]

        if lang == 'md':
            self.build_markdown(lang, body)
        else:
            self.build_code(lang, body)
1373331
protected function translit($string)
    {
        $stringOutput = (@iconv('UTF-8', 'ASCII//TRANSLIT', $string));
        if ($stringOutput === false) {
            $string = preg_replace('!([^0-9a-zA-Z\.,:;()/-_\s])!', '', $string); // use more explicit statement, alphanum dont do the job
            $stringOutput = (@iconv('UTF-8', 'ISO-8859-1//TRANSLIT', $string));
            if ($stringOutput === false) {
                throw new \Exception('Cant convert '.$string);
            }
        }

        return $stringOutput;
    }
557459
def _normalize_string(raw_str):
  
  return " ".join(
      token.strip()
      for token in tokenizer.encode(text_encoder.native_to_unicode(raw_str)))
486475
def convert(self, string, preprocess = None):
        
        string = unicode(preprocess(string) if preprocess else string, encoding="utf-8")
        if self.regex:
            return self.regex.sub(lambda x: self.substitutes[x.group()], string).encode('utf-8')
        else:
            return string
341704
def latinize_text(text, ascii=False):
    
    if text is None or not isinstance(text, six.string_types) or not len(text):
        return text

    if ascii:
        if not hasattr(latinize_text, '_ascii'):
            # Transform to latin, separate accents, decompose, remove
            # symbols, compose, push to ASCII
            latinize_text._ascii = Transliterator.createInstance('Any-Latin; NFKD; [:Symbol:] Remove; [:Nonspacing Mark:] Remove; NFKC; Accents-Any; Latin-ASCII')  # noqa
        return latinize_text._ascii.transliterate(text)

    if not hasattr(latinize_text, '_tr'):
        latinize_text._tr = Transliterator.createInstance('Any-Latin')
    return latinize_text._tr.transliterate(text)
204377
def transform(self, text):
        """"""
        return re.sub(self.regex, self.repl, text)
221240
def translate(self, dialect):
        """"""
        new_resultset = copy(self)
        new_resultset.dialect = dialect

        for result in new_resultset:
            for dimensionvalue in result.dimensionvalues:
                dimensionvalue.value = dimensionvalue.translate(dialect)
        return new_resultset
896482
def translate(self, text):
        

        # Reset substitution counter
        self.count = 0

        # Process text
        return self._make_regex().sub(self, text)