INNER CODE UNIT · Python
translation_pct
emanuele-f/PCAPdroid · tools/weblate.py:98
def translation_pct(locale):
"""Return translation percentage string for a locale on weblate/master."""
en_path = f"{STRINGS_BASE}/values/strings.xml"
path = locale_path(locale)
en_content = git("show", f"{REMOTE}/master:{en_path}").stdout
locale_result = git("show", f"{REMOTE}/master:{path}", check=False)
if locale_result.returncode != 0:
return "0%"
total = count_strings(en_content, translatable_only=True)
if total == 0:
return "0%"
translated = count_strings(locale_result.stdout)
return f"{100 * translated // total}%"
def locale_in_sync(locale):
"""True if the locale file is identical on weblate/master and HEAD."""
path = locale_path(locale)
return git("diff", "--quiet", f"{REMOTE}/master", "HEAD", "--", path,