arbret/frontend/app/components/IntlProvider.tsx
counterweight e2376855ce
Translate admin pages - Create admin.json files and translate all admin pages
- Create admin.json translation files for es, en, ca with all admin strings
- Update IntlProvider to include admin namespace
- Translate admin/invites/page.tsx - all strings now use translations
- Translate admin/trades/page.tsx - all strings now use translations
- Translate admin/price-history/page.tsx - all strings now use translations
- Translate admin/availability/page.tsx - all strings now use translations
- Add 'saving' key to common.json for all languages
- Fix linting errors: add t to useCallback dependencies
- All admin pages now fully multilingual
2025-12-26 11:49:50 +01:00

82 lines
2.5 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";
import esAdmin from "../../locales/es/admin.json";
import enAdmin from "../../locales/en/admin.json";
import caAdmin from "../../locales/ca/admin.json";
const messages = {
es: {
common: esCommon,
navigation: esNavigation,
exchange: esExchange,
auth: esAuth,
trades: esTrades,
invites: esInvites,
profile: esProfile,
admin: esAdmin,
},
en: {
common: enCommon,
navigation: enNavigation,
exchange: enExchange,
auth: enAuth,
trades: enTrades,
invites: enInvites,
profile: enProfile,
admin: enAdmin,
},
ca: {
common: caCommon,
navigation: caNavigation,
exchange: caExchange,
auth: caAuth,
trades: caTrades,
invites: caInvites,
profile: caProfile,
admin: caAdmin,
},
};
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} timeZone="Europe/Madrid">
{children}
</NextIntlClientProvider>
);
}