Adding a New Language
This guide explains how to add a new language to the Infowebplus application.
Step 1: Add Locale to Routing
Edit src/i18n/routing.ts:
export const locales = ['en', 'es', 'ro', 'fr'] as const; // Add 'fr' for French
export const defaultLocale = 'en' as const;
Step 2: Create Translation File
Create a new translation file in /messages/:
cp messages/en.json messages/fr.json
Edit messages/fr.json with French translations.
Step 3: Update Middleware
Update src/middleware.ts to include the new locale in the matcher:
export const config = {
matcher: ['/', '/(fr|en|es|ro)/:path*']
}
Step 4: Add Content in Sanity
Create localized content in Sanity Studio for the new language:
- Open Sanity Studio
- Create new documents with locale set to the new language
- Fill in translated content
Step 5: Test
- Start development server:
npm run dev - Navigate to
/fr(or your new locale) - Verify translations appear correctly