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
This commit is contained in:
chengyongru
2026-09-04 00:08:56 +08:00
committed by GitHub
parent 236185d4f5
commit 6c0f6bf0ee
3 changed files with 22 additions and 18 deletions
+1 -8
View File
@@ -50,14 +50,7 @@ export function LanguageSwitcher() {
>
{supportedLocales.map((option) => (
<DropdownMenuRadioItem key={option.code} value={option.code}>
<span className="flex min-w-0 items-center gap-2">
<span>{option.nativeLabel}</span>
{option.nativeLabel !== option.label ? (
<span className="truncate text-xs text-muted-foreground">
{option.label}
</span>
) : null}
</span>
{option.nativeLabel}
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
+10 -10
View File
@@ -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"];
+11
View File
@@ -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(<LanguageSwitcher />);
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();