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, ...actual,
useTranslation: () => ({ useTranslation: () => ({
t: (key: string, options?: Record<string, unknown>) => { t: (key: string, options?: Record<string, unknown>) => {
const prefix = options?.ns ? `${options.ns}.` : ''
if (options?.returnObjects) if (options?.returnObjects)
return [`${key}-feature-1`, `${key}-feature-2`] return [`${prefix}${key}-feature-1`, `${prefix}${key}-feature-2`]
if (options) return `${prefix}${key}`
return `${key}:${JSON.stringify(options)}`
return key
}, },
i18n: { i18n: {
language: 'en', language: 'en',

View File

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