@@ -78,6 +78,83 @@ struct ZaiMenuCardTests {
7878 #expect( mcp. secondaryValue == " 100 limit · 50 remaining " )
7979 }
8080
81+ @MainActor
82+ @Test
83+ func `model localizes zai usage sections in simplified chinese`() throws {
84+ let model = try CodexBarLocalizationOverride . $appLanguage. withValue ( " zh-Hans " ) {
85+ try Self . costSummaryModel ( style: . inlineSummary)
86+ }
87+
88+ #expect( model. providerDetails. map ( \. title) == [ " 配额详情 " , " 每小时 token " , " 每日 token " ] )
89+ #expect( model. providerDetails [ 0 ] . rows [ 0 ] . label == " Token 配额 " )
90+ #expect( model. providerDetails [ 0 ] . rows [ 0 ] . value == " 已使用 3% " )
91+ #expect( model. providerDetails [ 1 ] . rows [ 0 ] . label == " GLM-5.3 " )
92+ #expect( model. providerDetails [ 1 ] . chart? . title == " 每小时 token " )
93+ #expect( model. providerDetails [ 1 ] . chart? . unit == " token " )
94+ }
95+
96+ @Test
97+ func `model localizes zai quota values and periodic reset in simplified chinese`() throws {
98+ let now = Date ( )
99+ let details = try ProviderDetailSection ( title: " Quota details " , rows: [
100+ . init( label: " Token quota " , value: " 45% used " ) ,
101+ . init( label: " Session token quota " , value: " 0% used " ) ,
102+ . init( label: " MCP quota " , value: " 6.4% used " , secondaryValue: " 1000 limit · 936 remaining " ) ,
103+ . init( label: " search-prime " , value: " 64 " ) ,
104+ ] )
105+ let snapshot = UsageSnapshot (
106+ primary: RateWindow ( usedPercent: 0 , windowMinutes: 300 , resetsAt: nil , resetDescription: " 5-hour " ) ,
107+ secondary: RateWindow (
108+ usedPercent: 45 ,
109+ windowMinutes: 10080 ,
110+ resetsAt: now. addingTimeInterval ( 3 * 24 * 60 * 60 ) ,
111+ resetDescription: nil ) ,
112+ extraRateWindows: [ NamedRateWindow (
113+ id: " zai-mcp " ,
114+ title: " MCP " ,
115+ window: RateWindow ( usedPercent: 6.4 , windowMinutes: nil , resetsAt: nil , resetDescription: " MCP " ) ) ] ,
116+ details: [ details] ,
117+ updatedAt: now,
118+ identity: ProviderIdentitySnapshot (
119+ providerID: . zai,
120+ accountEmail: nil ,
121+ accountOrganization: nil ,
122+ loginMethod: " Pro " ) )
123+ let metadata = try #require( ProviderDefaults . metadata [ . zai] )
124+
125+ let model = CodexBarLocalizationOverride . $appLanguage. withValue ( " zh-Hans " ) {
126+ UsageMenuCardView . Model. make ( . init(
127+ provider: . zai,
128+ metadata: metadata,
129+ snapshot: snapshot,
130+ credits: nil ,
131+ creditsError: nil ,
132+ dashboard: nil ,
133+ dashboardError: nil ,
134+ tokenSnapshot: nil ,
135+ tokenError: nil ,
136+ account: AccountInfo ( email: nil , plan: nil ) ,
137+ isRefreshing: false ,
138+ lastError: nil ,
139+ usageBarsShowUsed: false ,
140+ resetTimeDisplayStyle: . countdown,
141+ tokenCostUsageEnabled: false ,
142+ showOptionalCreditsAndExtraUsage: true ,
143+ hidePersonalInfo: false ,
144+ now: now) )
145+ }
146+
147+ #expect( model. metrics. first? . resetText == " 每 5 小时重置 " )
148+ let rows = try #require( model. providerDetails. first? . rows)
149+ #expect( rows [ 0 ] . value == " 已使用 45% " )
150+ #expect( rows [ 1 ] . label == " 会话 Token 配额 " )
151+ #expect( rows [ 1 ] . value == " 已使用 0% " )
152+ #expect( rows [ 2 ] . label == " MCP 配额 " )
153+ #expect( rows [ 2 ] . value == " 已使用 6.4% " )
154+ #expect( rows [ 2 ] . secondaryValue == " 上限 1000 · 剩余 936 " )
155+ #expect( rows [ 3 ] . label == " search-prime " )
156+ }
157+
81158 @MainActor
82159 private static func costSummaryModel( style: CostSummaryDisplayStyle ) throws -> UsageMenuCardView . Model {
83160 let settings = testSettingsStore ( suiteName: " ZaiMenuCardTests-cost-summary- \( style. rawValue) " )
0 commit comments