From 6c0f6bf0ee4c4643d9dfb0b6d52793ea4aa8dbc3 Mon Sep 17 00:00:00 2001
From: chengyongru <61816729+chengyongru@users.noreply.github.com>
Date: Fri, 4 Sep 2026 00:08:56 +0800
Subject: [PATCH] fix(webui): show language names only in their native form
(#5646)
* fix(webui): show native language names only
* test(webui): assert native language names positively
---
webui/src/components/LanguageSwitcher.tsx | 9 +--------
webui/src/i18n/config.ts | 20 ++++++++++----------
webui/src/tests/i18n.test.tsx | 11 +++++++++++
3 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/webui/src/components/LanguageSwitcher.tsx b/webui/src/components/LanguageSwitcher.tsx
index c778aa164..0f3bd8c9a 100644
--- a/webui/src/components/LanguageSwitcher.tsx
+++ b/webui/src/components/LanguageSwitcher.tsx
@@ -50,14 +50,7 @@ export function LanguageSwitcher() {
>
{supportedLocales.map((option) => (
-
- {option.nativeLabel}
- {option.nativeLabel !== option.label ? (
-
- {option.label}
-
- ) : null}
-
+ {option.nativeLabel}
))}
diff --git a/webui/src/i18n/config.ts b/webui/src/i18n/config.ts
index 3f32ec962..08742acc3 100644
--- a/webui/src/i18n/config.ts
+++ b/webui/src/i18n/config.ts
@@ -1,16 +1,16 @@
export const LOCALE_STORAGE_KEY = "nanobot.locale";
export const supportedLocales = [
- { code: "en", label: "English", nativeLabel: "English" },
- { code: "zh-CN", label: "Chinese (Simplified)", nativeLabel: "简体中文" },
- { code: "zh-TW", label: "Chinese (Traditional)", nativeLabel: "繁體中文" },
- { code: "fr", label: "French", nativeLabel: "Français" },
- { code: "ja", label: "Japanese", nativeLabel: "日本語" },
- { code: "ko", label: "Korean", nativeLabel: "한국어" },
- { code: "es", label: "Spanish", nativeLabel: "Español" },
- { code: "pt-BR", label: "Portuguese (Brazil)", nativeLabel: "Português (Brasil)" },
- { code: "vi", label: "Vietnamese", nativeLabel: "Tiếng Việt" },
- { code: "id", label: "Indonesian", nativeLabel: "Bahasa Indonesia" },
+ { code: "en", nativeLabel: "English" },
+ { code: "zh-CN", nativeLabel: "简体中文" },
+ { code: "zh-TW", nativeLabel: "繁體中文" },
+ { code: "fr", nativeLabel: "Français" },
+ { code: "ja", nativeLabel: "日本語" },
+ { code: "ko", nativeLabel: "한국어" },
+ { code: "es", nativeLabel: "Español" },
+ { code: "pt-BR", nativeLabel: "Português (Brasil)" },
+ { code: "vi", nativeLabel: "Tiếng Việt" },
+ { code: "id", nativeLabel: "Bahasa Indonesia" },
] as const;
export type SupportedLocale = (typeof supportedLocales)[number]["code"];
diff --git a/webui/src/tests/i18n.test.tsx b/webui/src/tests/i18n.test.tsx
index 732a02e18..db2b4a6bb 100644
--- a/webui/src/tests/i18n.test.tsx
+++ b/webui/src/tests/i18n.test.tsx
@@ -452,6 +452,17 @@ describe("webui i18n", () => {
expect(resolveInitialLocale()).toBe("zh-CN");
});
+ it("lists each language by its native name", async () => {
+ const user = userEvent.setup();
+
+ render();
+ await user.click(screen.getByRole("button", { name: "Change language" }));
+
+ for (const { nativeLabel } of supportedLocales) {
+ expect(screen.getByRole("menuitemradio", { name: nativeLabel })).toBeInTheDocument();
+ }
+ });
+
it("switches UI copy and document locale through the language switcher", async () => {
const user = userEvent.setup();