Skip to main content

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:

  1. Open Sanity Studio
  2. Create new documents with locale set to the new language
  3. Fill in translated content

Step 5: Test

  1. Start development server: npm run dev
  2. Navigate to /fr (or your new locale)
  3. Verify translations appear correctly

Next Steps