Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added messages/en.json
Empty file.
11 changes: 11 additions & 0 deletions messages/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Navbar": {
"home": "Inicio",
"groups": "Grupos",
"dashboard": "Panel"
},
"Common": {
"welcome": "Bienvenido a Sorosave",
"connectWallet": "Conectar Billetera"
}
}
18 changes: 7 additions & 11 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
35 changes: 35 additions & 0 deletions src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<html lang={locale}>
<body className="antialiased">
<NextIntlClientProvider messages={messages}>
<Navbar />
<div className="min-h-screen bg-gray-50">
{children}
</div>
</NextIntlClientProvider>
</body>
</html>
);
}
23 changes: 0 additions & 23 deletions src/app/layout.tsx

This file was deleted.

15 changes: 15 additions & 0 deletions src/i18n/request.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {getRequestConfig} from 'next-intl/server';
import {routing} from './routing';

export default getRequestConfig(async ({requestLocale}) => {
let locale = await requestLocale;

if (!locale || !routing.locales.includes(locale as any)) {
locale = routing.defaultLocale;
}

return {
locale,
messages: (await import(`../../messages/${locale}.json`)).default
};
});
9 changes: 9 additions & 0 deletions src/i18n/routing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {defineRouting} from 'next-intl/routing';
import {createNavigation} from 'next-intl/navigation';

export const routing = defineRouting({
locales: ['en', 'es'],
defaultLocale: 'en'
});

export const {Link, redirect, usePathname, useRouter} = createNavigation(routing);
Empty file added src/middleware.ts
Empty file.