diff --git a/frontend/package-lock.json b/frontend/package-lock.json index daab0c904..f76c3b9bf 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -41,11 +41,11 @@ "d3-shape": "^3.2.0", "dagre": "^0.8.5", "dayjs": "^1.11.23", - "i18next": "^26.4.0", + "i18next": "^27.1.1", "motion": "^14.9.0", "react": "^19.2.5", "react-dom": "^19.3.0", - "react-i18next": "^17.0.14", + "react-i18next": "^18.0.0", "react-router-dom": "^7.18.4", "sql-formatter": "^15.8.2", "tailwind-merge": "^3.6.0", @@ -8658,9 +8658,9 @@ } }, "node_modules/i18next": { - "version": "26.4.0", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-26.4.0.tgz", - "integrity": "sha512-rsmK5bFqsD1AetSFSIa43wtNR4WpvvH4p0tLEsTxkC7QTrfdFm06nbQ95bh8Og4wwaCnUEcm9DVYL2cgxitiQg==", + "version": "27.1.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-27.1.1.tgz", + "integrity": "sha512-Qq3aJizS3RXQ30crhx9BKQLrHoa6GKpgrOJjVZ9vgj3EBxAddrmVfDNUrAMxSUimw5Jc+ld4SSZUAzf1q4nGyQ==", "funding": [ { "type": "individual", @@ -8676,6 +8676,9 @@ } ], "license": "MIT", + "engines": { + "node": ">=22" + }, "peerDependencies": { "typescript": "^5 || ^6 || ^7" }, @@ -10449,27 +10452,22 @@ } }, "node_modules/react-i18next": { - "version": "17.0.14", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-17.0.14.tgz", - "integrity": "sha512-ZpMBfJL3BiXPuYHj5QMY1GwvKJNhE1vCxOJQ8BoMBdHP5XONTfi/Qss1nuRlnFdIl72PKo2jPmw+fxuLjRFgaQ==", + "version": "18.0.0", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-18.0.0.tgz", + "integrity": "sha512-xXq/pcuMRwrW4iH0If/RjbPH3zuEqWVtaw4PjDsG54vx0FTook7aS3kop7DXy3g66wHkYUji8l7ZBrA8kfj67Q==", "license": "MIT", "dependencies": { - "@babel/runtime": "^7.29.7", - "html-parse-stringify": "^4.0.1", - "use-sync-external-store": "^1.6.0" + "html-parse-stringify": "^4.0.1" + }, + "engines": { + "node": ">=22" }, "peerDependencies": { - "i18next": ">= 26.2.0", - "react": ">= 16.8.0", + "i18next": ">= 27.0.0", + "react": ">= 18.0.0", "typescript": "^5 || ^6 || ^7" }, "peerDependenciesMeta": { - "react-dom": { - "optional": true - }, - "react-native": { - "optional": true - }, "typescript": { "optional": true } diff --git a/frontend/package.json b/frontend/package.json index 2d7872c93..3762184c5 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -47,11 +47,11 @@ "d3-shape": "^3.2.0", "dagre": "^0.8.5", "dayjs": "^1.11.23", - "i18next": "^26.4.0", + "i18next": "^27.1.1", "motion": "^14.9.0", "react": "^19.2.5", "react-dom": "^19.3.0", - "react-i18next": "^17.0.14", + "react-i18next": "^18.0.0", "react-router-dom": "^7.18.4", "sql-formatter": "^15.8.2", "tailwind-merge": "^3.6.0", diff --git a/frontend/src/components/common/NotificationBell.tsx b/frontend/src/components/common/NotificationBell.tsx index 61a2e7757..b3bb0a051 100644 --- a/frontend/src/components/common/NotificationBell.tsx +++ b/frontend/src/components/common/NotificationBell.tsx @@ -1,3 +1,4 @@ +import type { TFunction } from 'i18next'; import { useState } from 'react'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useNavigate } from 'react-router-dom'; @@ -175,7 +176,7 @@ export function NotificationBell() { function renderMessage( item: UserNotification, - t: (key: string, options?: Record) => string, + t: TFunction, ): string { const payload: UserNotificationPayload = item.payload ?? {}; const datasource = payload.datasource ?? '—'; diff --git a/frontend/src/i18n.d.ts b/frontend/src/i18n.d.ts index c4e07ac04..e6573807e 100644 --- a/frontend/src/i18n.d.ts +++ b/frontend/src/i18n.d.ts @@ -5,5 +5,6 @@ declare module 'i18next' { interface CustomTypeOptions { defaultNS: 'translation'; resources: { translation: typeof en }; + returnEmptyString: true; } } diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts index a0e8b548e..9e0f23cf8 100644 --- a/frontend/src/i18n.ts +++ b/frontend/src/i18n.ts @@ -51,6 +51,7 @@ i18n.use(initReactI18next).init({ lng: persistedLanguage, fallbackLng: 'en', interpolation: { escapeValue: false }, + returnEmptyString: true, }); export default i18n; diff --git a/frontend/src/pages/queries/buildTimelineStages.test.ts b/frontend/src/pages/queries/buildTimelineStages.test.ts index 3f6d4eb8f..ca37faaab 100644 --- a/frontend/src/pages/queries/buildTimelineStages.test.ts +++ b/frontend/src/pages/queries/buildTimelineStages.test.ts @@ -1,3 +1,4 @@ +import type { TFunction } from 'i18next'; import { describe, expect, it } from 'vitest'; import { buildTimelineStages } from './buildTimelineStages'; import type { @@ -8,8 +9,10 @@ import type { } from '@/types/api'; // Echoes the key plus its interpolation, so tests assert the shape without pinning English copy. -const t = (key: string, options?: Record) => - options ? `${key}:${Object.entries(options).map(([k, v]) => `${k}=${String(v)}`).join(',')}` : key; +const t = ((key: string, options?: Record) => + options + ? `${key}:${Object.entries(options).map(([k, v]) => `${k}=${String(v)}`).join(',')}` + : key) as unknown as TFunction; function reviewer(id: string, displayName: string | null, email: string) { return { id, email, display_name: displayName as string }; diff --git a/frontend/src/pages/queries/buildTimelineStages.ts b/frontend/src/pages/queries/buildTimelineStages.ts index 75a464dc1..93e37f27c 100644 --- a/frontend/src/pages/queries/buildTimelineStages.ts +++ b/frontend/src/pages/queries/buildTimelineStages.ts @@ -2,9 +2,9 @@ import type { TimelineStage } from '@/components/review/ApprovalTimeline'; import type { QueryDetail, ReviewDecisionDetail } from '@/types/api'; import { fmtDate, fmtNum } from '@/utils/dateFormat'; import { userDisplay } from '@/utils/userDisplay'; +import type { TFunction } from 'i18next'; -/** i18next's `t`, narrowed to what this builder needs — key plus optional interpolation. */ -type Translate = (key: string, options?: Record) => string; +type Translate = TFunction; export function buildTimelineStages( query: QueryDetail,