INNER CODE UNIT · Python

_calculate_char_limit

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

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:
        return text
    desc_match = TRANSLATION_DESC_PATTERN.search(text)
    if desc_match and CHAR_LIMIT_PATTERN.search(desc_match.group(1)):
        return text
    match = value_pattern.search(text)
    if not match:
        return text
    visible = _extract_visible_text(match.group(1))

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…