This commit is contained in:
Stephen Zhou 2025-12-26 17:03:33 +08:00
parent 6f2663deca
commit 40cb58cbef
No known key found for this signature in database
2 changed files with 5 additions and 6 deletions

View File

@ -15,11 +15,10 @@ vi.mock('react-i18next', async () => {
...actual,
useTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => {
const prefix = options?.ns ? `${options.ns}.` : ''
if (options?.returnObjects)
return [`${key}-feature-1`, `${key}-feature-2`]
if (options)
return `${key}:${JSON.stringify(options)}`
return key
return [`${prefix}${key}-feature-1`, `${prefix}${key}-feature-2`]
return `${prefix}${key}`
},
i18n: {
language: 'en',

View File

@ -16,9 +16,9 @@ const featuresTranslations: Record<string, string[]> = {
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => {
if (options?.returnObjects)
return featuresTranslations[key] || []
const prefix = options?.ns ? `${options.ns}.` : ''
if (options?.returnObjects)
return featuresTranslations[`${prefix}${key}`] || []
return `${prefix}${key}`
},
}),