arbret/frontend/app/components/IntlProvider.tsx
counterweight 246553c402
Phase 6: Translate User Pages - exchange, trades, invites, profile
- Expand exchange.json with all exchange page strings (page, steps, detailsStep, bookingStep, confirmationStep, priceDisplay)
- Create trades.json translation files for es, en, ca
- Create invites.json translation files for es, en, ca
- Create profile.json translation files for es, en, ca
- Translate exchange page and all components (ExchangeDetailsStep, BookingStep, ConfirmationStep, StepIndicator, PriceDisplay)
- Translate trades page (titles, sections, buttons, status labels)
- Translate invites page (titles, sections, status badges, copy button)
- Translate profile page (form labels, hints, placeholders, messages)
- Update IntlProvider to load all new namespaces
- All frontend tests passing
2025-12-25 22:19:13 +01:00

76 lines
2.2 KiB
TypeScript

"use client";
import { NextIntlClientProvider } from "next-intl";
import { ReactNode, useMemo } from "react";
import { useLanguage } from "../hooks/useLanguage";
// Import all locale messages
import esCommon from "../../locales/es/common.json";
import enCommon from "../../locales/en/common.json";
import caCommon from "../../locales/ca/common.json";
import esNavigation from "../../locales/es/navigation.json";
import enNavigation from "../../locales/en/navigation.json";
import caNavigation from "../../locales/ca/navigation.json";
import esExchange from "../../locales/es/exchange.json";
import enExchange from "../../locales/en/exchange.json";
import caExchange from "../../locales/ca/exchange.json";
import esAuth from "../../locales/es/auth.json";
import enAuth from "../../locales/en/auth.json";
import caAuth from "../../locales/ca/auth.json";
import esTrades from "../../locales/es/trades.json";
import enTrades from "../../locales/en/trades.json";
import caTrades from "../../locales/ca/trades.json";
import esInvites from "../../locales/es/invites.json";
import enInvites from "../../locales/en/invites.json";
import caInvites from "../../locales/ca/invites.json";
import esProfile from "../../locales/es/profile.json";
import enProfile from "../../locales/en/profile.json";
import caProfile from "../../locales/ca/profile.json";
const messages = {
es: {
common: esCommon,
navigation: esNavigation,
exchange: esExchange,
auth: esAuth,
trades: esTrades,
invites: esInvites,
profile: esProfile,
},
en: {
common: enCommon,
navigation: enNavigation,
exchange: enExchange,
auth: enAuth,
trades: enTrades,
invites: enInvites,
profile: enProfile,
},
ca: {
common: caCommon,
navigation: caNavigation,
exchange: caExchange,
auth: caAuth,
trades: caTrades,
invites: caInvites,
profile: caProfile,
},
};
interface IntlProviderProps {
children: ReactNode;
}
export function IntlProvider({ children }: IntlProviderProps) {
const { locale } = useLanguage();
const localeMessages = useMemo(() => {
return messages[locale] || messages.es;
}, [locale]);
return (
<NextIntlClientProvider locale={locale} messages={localeMessages}>
{children}
</NextIntlClientProvider>
);
}