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:
2026-07-11 19:01:44 +08:00
co-authored by Claude Sonnet 4.6
parent c67c489ab3
commit 87264a5497
12 changed files with 372 additions and 52 deletions
+30
View File
@@ -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)
})
})
})
})