INNER CODE UNIT · Python
limit
firebase/FirebaseUI-Android · scripts/translations/export_translations.py:44
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))
if not visible:
return text
limit = _calculate_char_limit(visible)