feat: i18n — EN/MS/ZH translations with cookie-based locale switching, report form translated
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FFDuBhMKvoWjrWT3ZnGmmr
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import en from '@/messages/en.json'
|
||||
import ms from '@/messages/ms.json'
|
||||
import zh from '@/messages/zh.json'
|
||||
|
||||
const NAMESPACES = ['ReportForm', 'IncidentType', 'MedicalStatus'] as const
|
||||
|
||||
NAMESPACES.forEach(ns => {
|
||||
describe(`${ns} namespace`, () => {
|
||||
const enKeys = Object.keys(en[ns])
|
||||
|
||||
it(`ms.${ns} has all keys present in en.${ns}`, () => {
|
||||
const msKeys = Object.keys(ms[ns])
|
||||
enKeys.forEach(key => expect(msKeys, `missing key: ${key}`).toContain(key))
|
||||
})
|
||||
|
||||
it(`zh.${ns} has all keys present in en.${ns}`, () => {
|
||||
const zhKeys = Object.keys(zh[ns])
|
||||
enKeys.forEach(key => expect(zhKeys, `missing key: ${key}`).toContain(key))
|
||||
})
|
||||
|
||||
it(`en.${ns} values are non-empty strings`, () => {
|
||||
enKeys.forEach(key => {
|
||||
const val = (en[ns] as Record<string, string>)[key]
|
||||
expect(typeof val).toBe('string')
|
||||
expect(val.length).toBeGreaterThan(0)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user