Feat: TrustGraph i18n & Documentation Translation Updates (#781)

Native CLI i18n: The TrustGraph CLI has built-in translation support
that dynamically loads language strings. You can test and use
different languages by simply passing the --lang flag (e.g., --lang
es for Spanish, --lang ru for Russian) or by configuring your
environment's LANG variable.

Automated Docs Translations: This PR introduces autonomously
translated Markdown documentation into several target languages,
including Spanish, Swahili, Portuguese, Turkish, Hindi, Hebrew,
Arabic, Simplified Chinese, and Russian.
This commit is contained in:
Alex Jenkins 2026-04-14 07:07:58 -04:00 committed by GitHub
parent 19f73e4cdc
commit f95fd4f052
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
560 changed files with 236300 additions and 99 deletions

View file

@ -0,0 +1,40 @@
from trustgraph.i18n import get_language_pack, get_translator, normalize_language
def test_normalize_language_handles_regions_and_accept_language():
assert normalize_language(None) == "en"
assert normalize_language("") == "en"
assert normalize_language("es-ES") == "es"
assert normalize_language("pt-BR") == "pt"
assert normalize_language("zh") == "zh-cn"
assert normalize_language("es-ES,es;q=0.9,en;q=0.8") == "es"
assert normalize_language("unknown") == "en"
def test_language_pack_loads_from_resources():
pack = get_language_pack("en")
assert isinstance(pack, dict)
# Key should exist and map to a non-empty string.
title = pack.get("cli.verify_system_status.title")
assert isinstance(title, str)
assert title.strip() != ""
def test_translator_formats_placeholders():
tr = get_translator("en")
out = tr.t(
"cli.verify_system_status.checking_attempt",
name="Pulsar",
attempt=2,
)
assert "Pulsar" in out
assert "2" in out
def test_translator_falls_back_to_key_for_unknown_keys():
tr = get_translator("en")
assert tr.t("missing.key") == "missing.key"