INNER CODE UNIT · Python

_extract_visible_text

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

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)
    limit = math.ceil(length * 1.5)
    return int(math.ceil(limit / 5.0) * 5)


def _add_char_limit(text, value_pattern):
    """Add [CHAR_LIMIT=xxx] to translation_description if missing."""
    if 'translation_description=' not in text:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…