alex-poor commented on code in PR #39357:
URL: https://github.com/apache/superset/pull/39357#discussion_r3197257331


##########
superset/views/base.py:
##########
@@ -436,6 +436,34 @@ def get_default_spinner_svg() -> str | None:
         return None
 
 
+def _load_language_pack(language: str | None) -> dict[str, Any] | None:
+    """Read the Jed language pack for ``language`` off disk.
+
+    Returns ``None`` for English, when the JSON file is missing, or when
+    it can't be parsed. The result is injected into the bootstrap payload
+    so the frontend can configure the translator synchronously before any
+    code-split chunk evaluates a module-level ``const X = t('...')``
+    (see upstream issue #35330).
+    """
+    if not language or language == "en":
+        return None
+    pack_path = os.path.join(
+        os.path.dirname(__file__),
+        "..",
+        "translations",
+        language,
+        "LC_MESSAGES",
+        "messages.json",
+    )
+    if not os.path.isfile(pack_path):
+        return None
+    try:
+        with open(pack_path, encoding="utf-8") as fp:
+            return cast(dict[str, Any], json.loads(fp.read()))
+    except (OSError, ValueError):
+        return None

Review Comment:
   Addressed in 9b2e2c84a5



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to