INNER CODE UNIT · Python

_add_char_limit

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

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))
    if not visible:
        return text
    limit = _calculate_char_limit(visible)
    return TRANSLATION_DESC_PATTERN.sub(
        r'\1 [CHAR_LIMIT=%d]\2' % limit, text, count=1)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…