INNER CODE UNIT · Python

_decode_entities

firebase/FirebaseUI-Android · scripts/translations/export_translations.py:26

def _decode_entities(text):
    """Decode XML entities and Android escape sequences to get true visible length."""
    text = ENTITY_PATTERN.sub(lambda m: XML_ENTITIES[m.group()], text)
    text = ESCAPE_PATTERN.sub('X', text)
    return text


def _extract_visible_text(value):
    """Strip XML tags and decode entities to get the visible text length."""
    text = XML_TAG_PATTERN.sub('', value).strip()
    text = _decode_entities(text)
    text = re.sub(r'\s+', ' ', text).strip()
    return text


def _calculate_char_limit(english_text):
    """Return ~1.5x the English text length, rounded up to the nearest 5."""
    length = len(english_text)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…