From 4c461a2ccd4d2c1293d54d86684fecdacd6d6776 Mon Sep 17 00:00:00 2001 From: BigBodyCobain <43977454+BigBodyCobain@users.noreply.github.com> Date: Mon, 3 Aug 2026 11:05:25 -0600 Subject: [PATCH] Wire Persian into Telegram OSINT translate labels and locale docs. Co-authored-by: Cursor --- CONTRIBUTING.md | 4 +++- backend/services/telegram_translate.py | 2 ++ backend/tests/test_telegram_translate.py | 2 ++ .../MaplibreViewer/popups/TelegramOsintPopup.tsx | 1 + frontend/src/i18n/index.tsx | 7 ++++++- frontend/src/i18n/translations/fa.json | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 91b0cd3..9edd271 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,8 +62,10 @@ A PR that adds a new language is harder to review than one that fixes typos in a ### What about adding a new language? -We welcome new languages. The mechanical setup is documented in the header comment of `frontend/src/i18n/index.ts`. Beyond that: +We welcome new languages. The mechanical setup is documented in the header comment of `frontend/src/i18n/index.tsx`. Beyond that: +- Register the locale in `backend/services/telegram_translate.py` (`_LOCALE_TO_GOOGLE` and `_SOURCE_LANG_LABELS`) and the matching fallback labels in `frontend/src/components/MaplibreViewer/popups/TelegramOsintPopup.tsx`. Simple codes like `fa` already pass through to Google Translate, but without the labels the UI shows raw codes (e.g. `FA`) for source language, and aliases like `zh` → `zh-CN` need an explicit map entry. +- For RTL languages, add the locale to `RTL_LOCALES` in `frontend/src/i18n/index.tsx` and smoke-test the map chrome (sidebar, modals, popups) with that locale selected — `dir="rtl"` can mirror flex layouts that were designed LTR. - We are more likely to merge a new language quickly if at least one reviewer in the maintainer's network speaks it. - If you are the *only* speaker of the target language reading this repo, your translation is welcome but the merge timeline will be longer while a reviewer is found. - Partial translations are fine — the system falls back to English for any missing key. diff --git a/backend/services/telegram_translate.py b/backend/services/telegram_translate.py index 471a99f..15ac9fd 100644 --- a/backend/services/telegram_translate.py +++ b/backend/services/telegram_translate.py @@ -34,6 +34,7 @@ _SOURCE_LANG_LABELS = { "ru": "Russian", "en": "English", "ar": "Arabic", + "fa": "Persian", "he": "Hebrew", "zh-cn": "Chinese", "fr": "French", @@ -48,6 +49,7 @@ _CACHE_MAX = 512 _LOCALE_TO_GOOGLE = { "en": "en", "fr": "fr", + "fa": "fa", "zh-cn": "zh-CN", "zh": "zh-CN", } diff --git a/backend/tests/test_telegram_translate.py b/backend/tests/test_telegram_translate.py index 6960a6e..0cb272d 100644 --- a/backend/tests/test_telegram_translate.py +++ b/backend/tests/test_telegram_translate.py @@ -41,11 +41,13 @@ def test_apply_post_translation_adds_fields(monkeypatch): def test_normalize_translate_target_maps_ui_locales(): assert telegram_translate.normalize_translate_target("zh-CN") == "zh-CN" assert telegram_translate.normalize_translate_target("fr") == "fr" + assert telegram_translate.normalize_translate_target("fa") == "fa" def test_source_lang_label_avoids_uk_country_confusion(): assert telegram_translate.source_lang_label("uk") == "Ukrainian" assert telegram_translate.source_lang_label("ru") == "Russian" + assert telegram_translate.source_lang_label("fa") == "Persian" def test_polish_translation_expands_bpla_shorthand(): diff --git a/frontend/src/components/MaplibreViewer/popups/TelegramOsintPopup.tsx b/frontend/src/components/MaplibreViewer/popups/TelegramOsintPopup.tsx index a36f24a..a57fac9 100644 --- a/frontend/src/components/MaplibreViewer/popups/TelegramOsintPopup.tsx +++ b/frontend/src/components/MaplibreViewer/popups/TelegramOsintPopup.tsx @@ -83,6 +83,7 @@ function sourceLangLabel(post: TelegramOsintPost): string { ru: 'Russian', en: 'English', ar: 'Arabic', + fa: 'Persian', he: 'Hebrew', 'zh-cn': 'Chinese', fr: 'French', diff --git a/frontend/src/i18n/index.tsx b/frontend/src/i18n/index.tsx index e54e426..9a735c0 100644 --- a/frontend/src/i18n/index.tsx +++ b/frontend/src/i18n/index.tsx @@ -24,7 +24,12 @@ const RTL_LOCALES: ReadonlySet = new Set(['fa']); * 2. Import it above and add to `translations` below * 3. Add an entry here * 4. Extend the `Locale` type - * 5. Read CONTRIBUTING.md — translations must be technically faithful + * 5. If the language is RTL, add its code to `RTL_LOCALES` + * 6. Map the locale in `backend/services/telegram_translate.py` + * (`_LOCALE_TO_GOOGLE` + `_SOURCE_LANG_LABELS`) and the fallback + * labels in `TelegramOsintPopup.tsx` so Telegram OSINT posts + * translate into the UI language + * 7. Read CONTRIBUTING.md — translations must be technically faithful * to the English source. Politically loaded substitutions or * framing aligned with state propaganda from ANY country will * be rejected. diff --git a/frontend/src/i18n/translations/fa.json b/frontend/src/i18n/translations/fa.json index 699043b..92435af 100644 --- a/frontend/src/i18n/translations/fa.json +++ b/frontend/src/i18n/translations/fa.json @@ -1,6 +1,6 @@ { "brand": { - "title": "S H A D O W B R O K E R", + "title": "S H A D O W B R O K E R", "subtitle": "رهگیری تهدیدات جهانی", "systemMetrics": "OPTIC VIS:113 SRC:180 DENS:1.42 0.8ms" },