Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

i18n: Remove mobile.json-related codepaths.

Alex Vandiverd1995687c9c8
diff --git a/locale/mobile_info.json b/locale/mobile_info.json
deleted file mode 100644
index e35bfc5534f..00000000000
--- a/locale/mobile_info.json
+++ /dev/null
@@ -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
- }
-}
diff --git a/tools/i18n/process-mobile-i18n b/tools/i18n/process-mobile-i18n
deleted file mode 100755
index 2b19f57754a..00000000000
--- a/tools/i18n/process-mobile-i18n
+++ /dev/null
@@ -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)
diff --git a/tools/i18n/sync-translations b/tools/i18n/sync-translations
index 3dbbe2a6ecb..babc0bf1de5 100755
--- a/tools/i18n/sync-translations
+++ b/tools/i18n/sync-translations
@@ -19,4 +19,3 @@ done
./tools/i18n/update-for-legacy-translations
./manage.py compilemessages --ignore='*'
-./tools/i18n/process-mobile-i18n
diff --git a/zerver/management/commands/compilemessages.py b/zerver/management/commands/compilemessages.py
index 9314c238a9b..f58687bd95a 100644
--- a/zerver/management/commands/compilemessages.py
+++ b/zerver/management/commands/compilemessages.py
@@ -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