提交一次全量代码
This commit is contained in:
33
client/src/tests/i18nLocales.spec.ts
Normal file
33
client/src/tests/i18nLocales.spec.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import enUS from '@/i18n/locales/en-US'
|
||||
import thTH from '@/i18n/locales/th-TH'
|
||||
import zhCN from '@/i18n/locales/zh-CN'
|
||||
|
||||
describe('reservation i18n locales', () => {
|
||||
it('keeps Chinese, English, and Thai locale keys aligned', () => {
|
||||
const zhKeys = collectKeyPaths(zhCN)
|
||||
|
||||
expect(collectKeyPaths(enUS)).toEqual(zhKeys)
|
||||
expect(collectKeyPaths(thTH)).toEqual(zhKeys)
|
||||
})
|
||||
|
||||
it('includes Thai labels for the P0 reservation navigation', () => {
|
||||
expect(thTH.nav.orders).toBe('รายการออเดอร์')
|
||||
expect(thTH.nav.taskQueue).toBe('คิวงาน')
|
||||
expect(thTH.taskList.viewConversation).toBe('ดูเธรดอีเมล')
|
||||
})
|
||||
})
|
||||
|
||||
function collectKeyPaths(value: unknown, prefix = ''): string[] {
|
||||
if (!isRecord(value)) {
|
||||
return [prefix]
|
||||
}
|
||||
return Object.keys(value)
|
||||
.sort()
|
||||
.flatMap((key) => collectKeyPaths(value[key], prefix ? `${prefix}.${key}` : key))
|
||||
}
|
||||
|
||||
function isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
||||
}
|
||||
Reference in New Issue
Block a user