def latinize_text(text, ascii=False):
if text is None or not isinstance(text, six.string_types) or not len(text):<EOL><INDENT>return text<EOL><DEDENT>if ascii:<EOL><INDENT>if not hasattr(latinize_text, '<STR_LIT>'):<EOL><INDENT>latinize_text._ascii = Transliterator.createInstance('<STR_LIT>')  <EOL><DEDENT>return latinize_text._ascii.transliterate(text)<EOL><DEDENT>if not hasattr(latinize_text, '<STR_LIT>'):<EOL><INDENT>latinize_text._tr = Transliterator.createInstance('<STR_LIT>')<EOL><DEDENT>return latinize_text._tr.transliterate(text)<EOL>
Transliterate the given text to the latin script.

    This attempts to convert a given text to latin script using the
    closest match of characters vis a vis the original script.