"use client"; import { useTranslation } from "react-i18next"; import type { TFunction } from "i18next"; import type { ReportDefinition, ReportField } from "@/config/reportConfig"; /** FP-MTMS Version Checklist | Functions Ref. No. 69 | v1.0.2 | 2026-09-10 */ export function useReportLabels() { const { t, i18n } = useTranslation("report"); const reportTitle = (report: Pick) => t(`reports.${report.id}.title`, { defaultValue: report.title }); const fieldLabel = ( reportId: string, field: Pick, ) => t(`reports.${reportId}.fields.${field.name}`, { defaultValue: field.label, }); const fieldHint = (reportId: string, fieldName: string, fallback = "") => { const key = `reports.${reportId}.fieldHints.${fieldName}`; if (!i18n.exists(key, { ns: "report" })) return fallback; return String(t(key, { defaultValue: fallback })); }; const optionLabel = ( reportId: string, fieldName: string, opt: { label: string; value: string }, ) => t( [ `reports.${reportId}.options.${fieldName}.${opt.value}`, `options.${opt.value}`, ], { defaultValue: opt.label }, ); const categoryTitle = (id: string, fallback: string) => t(`categories.${id}`, { defaultValue: fallback }); return { t, i18n, reportTitle, fieldLabel, fieldHint, optionLabel, categoryTitle }; } export function reportExcelT( t: TFunction | undefined, key: string, fallback: string, ): string { if (!t) return fallback; return String(t(key, { defaultValue: fallback })); }