mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-30 02:14:43 +08:00
feat(i18n): add Traditional Chinese localization (#3093)
* Add Traditional Chinese localization * fix: address zh-TW formatting and token units - Format `zh-TW.json` with Prettier. - Use Traditional Chinese `萬` and `億` units for zh-TW token summaries. - Add usage formatting coverage for Traditional Chinese locale aliases. --------- Co-authored-by: Jason <farion1231@gmail.com>
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
formatTokensShort,
|
||||
getLocaleFromLanguage,
|
||||
} from "@/components/usage/format";
|
||||
|
||||
describe("usage format helpers", () => {
|
||||
it("formats Traditional Chinese token units with Traditional characters", () => {
|
||||
expect(formatTokensShort(12_345, "zh-TW")).toBe("1.2 萬");
|
||||
expect(formatTokensShort(123_456_789, "zh-Hant", 2)).toBe("1.23 億");
|
||||
});
|
||||
|
||||
it("resolves Traditional Chinese locale aliases", () => {
|
||||
expect(getLocaleFromLanguage("zh_TW")).toBe("zh-TW");
|
||||
expect(getLocaleFromLanguage("zh-HK")).toBe("zh-TW");
|
||||
});
|
||||
});
|
||||
@@ -81,6 +81,29 @@ describe("useSettingsForm Hook", () => {
|
||||
expect(changeLanguageSpy).toHaveBeenCalledWith("ja");
|
||||
});
|
||||
|
||||
it("should support traditional chinese language preference aliases", async () => {
|
||||
useSettingsQueryMock.mockReturnValue({
|
||||
data: {
|
||||
showInTray: true,
|
||||
minimizeToTrayOnClose: true,
|
||||
enableClaudePluginIntegration: false,
|
||||
claudeConfigDir: "/Users/demo",
|
||||
codexConfigDir: null,
|
||||
language: "zh-Hant",
|
||||
},
|
||||
isLoading: false,
|
||||
});
|
||||
|
||||
const { result } = renderHook(() => useSettingsForm());
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.settings?.language).toBe("zh-TW");
|
||||
});
|
||||
|
||||
expect(result.current.initialLanguage).toBe("zh-TW");
|
||||
expect(changeLanguageSpy).toHaveBeenCalledWith("zh-TW");
|
||||
});
|
||||
|
||||
it("should prioritize reading language from local storage in readPersistedLanguage", () => {
|
||||
useSettingsQueryMock.mockReturnValue({
|
||||
data: null,
|
||||
|
||||
Reference in New Issue
Block a user