i18n: Remove mobile.json-related codepaths.

This commit is contained in:
Alex Vandiver
2025-06-28 04:53:48 +00:00
committed by Tim Abbott
parent a117181fdb
commit d1995687c9
4 changed files with 0 additions and 257 deletions

View File

@@ -1,190 +0,0 @@
{
"ar": {
"not_translated": 98,
"total": 457
},
"be": {
"not_translated": 1,
"total": 457
},
"bg": {
"not_translated": 305,
"total": 457
},
"bn": {
"not_translated": 446,
"total": 457
},
"bqi": {
"not_translated": 391,
"total": 457
},
"ca": {
"not_translated": 244,
"total": 457
},
"cs": {
"not_translated": 1,
"total": 457
},
"cy": {
"not_translated": 208,
"total": 457
},
"da": {
"not_translated": 201,
"total": 457
},
"de": {
"not_translated": 1,
"total": 457
},
"el": {
"not_translated": 426,
"total": 457
},
"en_GB": {
"not_translated": 1,
"total": 457
},
"eo": {
"not_translated": 422,
"total": 457
},
"es": {
"not_translated": 1,
"total": 457
},
"fa": {
"not_translated": 0,
"total": 457
},
"fi": {
"not_translated": 0,
"total": 457
},
"fr": {
"not_translated": 53,
"total": 457
},
"gl": {
"not_translated": 362,
"total": 457
},
"gu": {
"not_translated": 47,
"total": 457
},
"hi": {
"not_translated": 327,
"total": 457
},
"hu": {
"not_translated": 179,
"total": 457
},
"id": {
"not_translated": 362,
"total": 457
},
"it": {
"not_translated": 0,
"total": 457
},
"ja": {
"not_translated": 85,
"total": 457
},
"ko": {
"not_translated": 254,
"total": 457
},
"lt": {
"not_translated": 428,
"total": 457
},
"lv": {
"not_translated": 315,
"total": 457
},
"ml": {
"not_translated": 423,
"total": 457
},
"mn": {
"not_translated": 162,
"total": 457
},
"nl": {
"not_translated": 265,
"total": 457
},
"no": {
"not_translated": 449,
"total": 457
},
"pl": {
"not_translated": 0,
"total": 457
},
"pt": {
"not_translated": 1,
"total": 457
},
"pt_PT": {
"not_translated": 1,
"total": 457
},
"ro": {
"not_translated": 163,
"total": 457
},
"ru": {
"not_translated": 0,
"total": 457
},
"si": {
"not_translated": 307,
"total": 457
},
"sl": {
"not_translated": 0,
"total": 457
},
"sr": {
"not_translated": 62,
"total": 457
},
"sv": {
"not_translated": 403,
"total": 457
},
"ta": {
"not_translated": 395,
"total": 457
},
"tl": {
"not_translated": 435,
"total": 457
},
"tr": {
"not_translated": 1,
"total": 457
},
"uk": {
"not_translated": 1,
"total": 457
},
"vi": {
"not_translated": 159,
"total": 457
},
"zh_Hans": {
"not_translated": 0,
"total": 457
},
"zh_TW": {
"not_translated": 0,
"total": 457
}
}

View File

@@ -1,53 +0,0 @@
#!/usr/bin/env python3
import os
import re
from subprocess import check_output
import orjson
def get_json_filename(locale: str) -> str:
return f"locale/{locale}/mobile.json"
def get_locales() -> list[str]:
output = check_output(["git", "ls-files", "locale"], text=True)
tracked_files = output.split()
regex = re.compile(r"locale/(\w+)/LC_MESSAGES/django.po")
locales = ["en"]
for tracked_file in tracked_files:
matched = regex.search(tracked_file)
if matched:
locales.append(matched.group(1))
return locales
def get_translation_stats(resource_path: str) -> dict[str, int]:
with open(resource_path, "rb") as raw_resource_file:
raw_info = orjson.loads(raw_resource_file.read())
total = len(raw_info)
not_translated = len([i for i in raw_info.items() if i[1] == ""])
return {"total": total, "not_translated": not_translated}
translation_stats: dict[str, dict[str, int]] = {}
locale_paths = [] # List[str]
for locale in get_locales():
path = get_json_filename(locale)
if os.path.exists(path):
stats = get_translation_stats(path)
translation_stats.update({locale: stats})
locale_paths.append(path)
stats_path = os.path.join("locale", "mobile_info.json")
with open(stats_path, "wb") as f:
f.write(
orjson.dumps(
translation_stats,
option=orjson.OPT_APPEND_NEWLINE | orjson.OPT_INDENT_2 | orjson.OPT_SORT_KEYS,
)
)
print("Mobile stats file created at: " + stats_path)

View File

@@ -19,4 +19,3 @@ done
./tools/i18n/update-for-legacy-translations
./manage.py compilemessages --ignore='*'
./tools/i18n/process-mobile-i18n

View File

@@ -157,17 +157,4 @@ class Command(compilemessages.Command):
if value == "":
not_translated += 1
# mobile stats
with open(os.path.join(locale_path, "mobile_info.json"), "rb") as mob:
mobile_info = orjson.loads(mob.read())
try:
info = mobile_info[locale]
except KeyError:
if self.strict:
raise
info = {"total": 0, "not_translated": 0}
total += info["total"]
not_translated += info["not_translated"]
return (total - not_translated) * 100 // total