Skip to main content
ShipFree is designed with internationalization (i18n) in mind, though the full next-intl integration is optional. The architecture supports multiple languages through locale-based routing and translation management.
While the boilerplate includes the structure for i18n, you can choose to implement it based on your needs. The default setup supports English, French, and Spanish.

Supported Languages

English

Default language (en)

French

French translations (fr)

Spanish

Spanish translations (es)

Architecture Overview

ShipFree uses locale-based routing where all pages are under a [locale] dynamic segment:
The locale is extracted from the URL path (e.g., /en/dashboard, /fr/dashboard, /es/dashboard).

Configuration

When implementing next-intl, you’ll typically have these configuration files:

Routing Configuration

i18n/routing.ts

Request Configuration

i18n/request.ts

Translation Files

Translations are stored as JSON files in src/messages/:
src/messages/en.json

Using Translations

In Server Components

src/app/[locale]/(site)/page.tsx
In Server Components, use getTranslations from next-intl/server with await.

In Client Components

src/components/navbar.tsx
In Client Components, use the useTranslations hook without await.

With Parameters

src/messages/en.json

Rich Text & Formatting

src/messages/en.json

Locale-Aware Navigation

The Link component from @/i18n/routing automatically prefixes URLs with the current locale.

Programmatic Navigation

Locale Switcher

Metadata & SEO

src/app/[locale]/(site)/layout.tsx

Date & Number Formatting

Dates

Numbers & Currency

Adding a New Language

1

Create Translation File

Add a new JSON file in src/messages/ (e.g., de.json for German):
src/messages/de.json
2

Update Routing Config

Add the locale to your routing configuration:
i18n/routing.ts
3

Update Locale Switcher

Add the new language option to your locale switcher component.

Next.js Middleware

Configure middleware to handle locale detection:
middleware.ts

Best Practices

Namespace Keys

Organize translations by feature or page for easier maintenance

Use TypeScript

Generate types from translation files for autocomplete

Pluralization

Use next-intl’s pluralization features for count-based text

SEO Optimization

Set proper lang attribute and hreflang tags for each locale

Translation Keys Type Safety

Generate TypeScript types from your translation files:

Environment Variables

.env

Common Patterns

Conditional Rendering

Server Actions

src/app/actions/user.ts

Further Reading

next-intl Docs

Official next-intl documentation

Routing Guide

Learn about locale-based routing

Formatting

Date, time, and number formatting

Best Practices

i18n best practices and workflows