22// SPDX-License-Identifier: Apache-2.0
33
44import { afterEach , describe , expect , it } from "vitest" ;
5- import { getI18nLocale , resolveLocale , setI18nLocale , supportedLocales , t } from "./index" ;
5+ import { getI18nLocale , normalizeLocale , resolveLocale , setI18nLocale , supportedLocales , t } from "./index" ;
66
77describe ( "i18n" , ( ) => {
88 afterEach ( ( ) => {
@@ -46,6 +46,22 @@ describe("i18n", () => {
4646 setI18nLocale ( "zh-CN" ) ;
4747 expect ( t ( "Client Version {version}" , { version : "0.14.5" } ) ) . toBe ( "客户端版本 0.14.5" ) ;
4848 expect ( t ( "Open Clipboard URL ({host})" , { host : "example.com" } ) ) . toBe ( "打开剪贴板 URL(example.com)" ) ;
49+ expect ( t ( 'Secret "{name}" already exists' , { name : "MY_TOKEN" } ) ) . toBe ( "密钥“MY_TOKEN”已存在" ) ;
50+ expect ( t ( "Go to {label} ({path})" , { label : "桌面" , path : "~/Desktop" } ) ) . toBe ( "转到 桌面(~/Desktop)" ) ;
51+ } ) ;
52+
53+ it ( "translates review feedback strings" , ( ) => {
54+ setI18nLocale ( "zh-CN" ) ;
55+ expect ( t ( "The current secret value is not shown by default for security purposes." ) ) . toBe (
56+ "出于安全考虑,当前密钥值默认不会显示。"
57+ ) ;
58+ expect ( t ( "{minutes}m" , { minutes : 5 } ) ) . toBe ( "5 分钟" ) ;
59+ expect (
60+ t (
61+ "{count} file{plural} rejected (unsupported type): {fileNames}. Supported: images, PDFs, and text/code files." ,
62+ { count : 2 , plural : "s" , fileNames : "demo.exe" }
63+ )
64+ ) . toBe ( "已拒绝 2 个文件(不支持的类型):demo.exe。支持图片、PDF、文本和代码文件。" ) ;
4965 } ) ;
5066
5167 it ( "falls back to the original key when a translation is missing" , ( ) => {
@@ -58,5 +74,7 @@ describe("i18n", () => {
5874 expect ( resolveLocale ( null , "ja-JP" ) ) . toBe ( "ja-JP" ) ;
5975 expect ( resolveLocale ( "en" , "zh-CN" ) ) . toBe ( "en-US" ) ;
6076 expect ( resolveLocale ( "fr-FR" , "fr-FR" ) ) . toBe ( "en-US" ) ;
77+ expect ( normalizeLocale ( "en" ) ) . toBe ( "en-US" ) ;
78+ expect ( normalizeLocale ( "zh_Hans_CN" ) ) . toBe ( "zh-CN" ) ;
6179 } ) ;
6280} ) ;
0 commit comments