mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 11:19:51 +08:00
fix(i18n): stop splitting translation keys on ":"
This commit is contained in:
@@ -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,
|
||||
},
|
||||
|
||||
13
web/tests/i18n-colon-keys.spec.ts
Normal file
13
web/tests/i18n-colon-keys.spec.ts
Normal 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('对话列表:')
|
||||
})
|
||||
Reference in New Issue
Block a user