diff --git a/scripts/gp/extract_backend_strings.py b/scripts/gp/extract_backend_strings.py index f7a502095d..4af93bc850 100644 --- a/scripts/gp/extract_backend_strings.py +++ b/scripts/gp/extract_backend_strings.py @@ -51,7 +51,7 @@ def collect_strings() -> dict[str, str]: print(f" SKIP {modname}: {e}") continue - for attr_name, cls in vars(module).items(): + for cls in vars(module).values(): if not isinstance(cls, type): continue # Only process classes defined in this module (avoid re-processing imports) @@ -109,7 +109,9 @@ def main() -> None: print("Scanning lfx.components for translatable strings...") strings = collect_strings() print( - f"Found {len(strings)} translatable keys across {sum(1 for k in strings if k.endswith('.display_name') and '.inputs.' not in k and '.outputs.' not in k)} components." + f"Found {len(strings)} translatable keys across " + f"{sum(1 for k in strings if k.endswith('.display_name') and '.inputs.' not in k and '.outputs.' not in k)}" + " components." ) new_content = json.dumps(strings, ensure_ascii=False, indent=2) + "\n" diff --git a/scripts/gp/tests/test_extract_backend_strings.py b/scripts/gp/tests/test_extract_backend_strings.py index f7e928b07b..bf6a4db815 100644 --- a/scripts/gp/tests/test_extract_backend_strings.py +++ b/scripts/gp/tests/test_extract_backend_strings.py @@ -34,6 +34,7 @@ class TestExtractBackendStrings: def test_writes_keys_in_order_returned_by_collect_strings(self, tmp_path): """main() writes keys in the order collect_strings() returns them. + collect_strings() always returns sorted keys, so the output is sorted in practice. """ output_file = tmp_path / "en.json" diff --git a/src/backend/base/langflow/main.py b/src/backend/base/langflow/main.py index bd36250ab3..da31fc8de2 100644 --- a/src/backend/base/langflow/main.py +++ b/src/backend/base/langflow/main.py @@ -518,10 +518,7 @@ def create_app(): """ accept_lang = request.headers.get("Accept-Language", "en") primary = accept_lang.split(",")[0].strip() - if primary.lower().startswith("zh-hans"): - locale = "zh-Hans" - else: - locale = primary.split("-")[0] or "en" + locale = "zh-Hans" if primary.lower().startswith("zh-hans") else primary.split("-")[0] or "en" request.state.locale = locale return await call_next(request)