fix(i18n): stop splitting translation keys on ":"

This commit is contained in:
이정현
2026-10-30 11:00:13 +09:00
parent a4fa63b6e2
commit 2f72c1171b
2 changed files with 15 additions and 0 deletions

View File

@@ -22,9 +22,11 @@ export function initI18n(language?: unknown) {
fallbackLng: "en",
// Use a single default namespace to keep lookups simple.
// We intentionally keep keySeparator disabled so keys like "Generating..." remain valid.
// nsSeparator too: keys like "Query:" or "http://localhost:8080" would otherwise split as ns:key.
defaultNS: "app",
ns: ["app"],
keySeparator: false,
nsSeparator: false,
interpolation: {
escapeValue: false,
},

View File

@@ -0,0 +1,13 @@
import { expect, it } from 'vitest'
import { ensureLanguage, initI18n } from '@/i18n/init'
it('looks up natural-language keys that contain a colon as whole keys', async () => {
const i18n = initI18n()
await ensureLanguage('zh')
const en = i18n.getFixedT('en', 'app')
const zh = i18n.getFixedT('zh', 'app')
expect(en('Query:')).toBe('Query:')
expect(en('http://localhost:8080')).toBe('http://localhost:8080')
expect(zh('Query:')).toBe('问题:')
expect(zh('Conversations:')).toBe('对话列表:')
})