diff --git a/messages/en.json b/messages/en.json new file mode 100644 index 0000000..e69de29 diff --git a/messages/es.json b/messages/es.json new file mode 100644 index 0000000..48e1bf4 --- /dev/null +++ b/messages/es.json @@ -0,0 +1,11 @@ +{ + "Navbar": { + "home": "Inicio", + "groups": "Grupos", + "dashboard": "Panel" + }, + "Common": { + "welcome": "Bienvenido a Sorosave", + "connectWallet": "Conectar Billetera" + } +} \ No newline at end of file diff --git a/next.config.js b/next.config.js index 55d4c9b..a1ab0b7 100644 --- a/next.config.js +++ b/next.config.js @@ -1,15 +1,11 @@ +const createNextIntlPlugin = require('next-intl/plugin'); + +const withNextIntl = createNextIntlPlugin('./src/i18n/request.ts'); + /** @type {import('next').NextConfig} */ const nextConfig = { + // Mantén aquí cualquier otra configuración que ya tuviera el proyecto original reactStrictMode: true, - webpack: (config) => { - config.resolve.fallback = { - ...config.resolve.fallback, - buffer: false, - crypto: false, - stream: false, - }; - return config; - }, }; - -module.exports = nextConfig; + +module.exports = withNextIntl(nextConfig); \ No newline at end of file diff --git a/package.json b/package.json index 7e788f6..d24c947 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,13 @@ "lint": "next lint" }, "dependencies": { + "next-intl": "^3.11.0", "@sorosave/sdk": "workspace:*", "@stellar/freighter-api": "^2.0.0", "next": "^14.2.0", "react": "^18.3.0", "react-dom": "^18.3.0" + }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/src/app/[locale]/layout.tsx b/src/app/[locale]/layout.tsx new file mode 100644 index 0000000..5483d38 --- /dev/null +++ b/src/app/[locale]/layout.tsx @@ -0,0 +1,35 @@ +import { NextIntlClientProvider } from 'next-intl'; +import { getMessages } from 'next-intl/server'; +import { notFound } from 'next/navigation'; +import { routing } from '@/src/i18n/routing'; +import { Navbar } from '@/src/components/Navbar'; +import "../globals.css"; + +export default async function LocaleLayout({ + children, + params: { locale } +}: { + children: React.ReactNode; + params: { locale: string }; +}) { + // 1. Validar el idioma (solo permitimos 'en' o 'es') + if (!routing.locales.includes(locale as any)) { + notFound(); + } + + // 2. Cargar los mensajes correspondientes al idioma + const messages = await getMessages(); + + return ( + +
+