Multi-language Feature Overview
PreLaunch comes with built-in multi-language support, offering English and Chinese languages by default, which you can easily extend to other languages. This functionality is implemented using next-intl and features:- Support for multi-language routes (e.g.,
/zh/pricing
and/en/pricing
) - Language switching without page refreshes
- Automatic default language selection based on user browser settings
- Support for rich text and formatted content
Supported Languages
Currently, PreLaunch supports the following languages by default:Language Code | Language Name |
---|---|
en | English |
zh | Chinese |
Using Multi-language Features
Content Translation
All translated text is stored in thelocales/
directory:
Using Translations in Components
In React components:Using Translations in Pages
In Next.js pages:Adding New Languages
To add a new language, follow these steps:1. Update Configuration
Edit themiddleware.ts
file to add the new language code:
2. Create Translation Files
Copy an existing language directory (such aslocales/en/
) and create a new language directory:
3. Add Language Selector
PreLaunch already includes a language selector component that will automatically display new languages in the dropdown menu once added.Best Practices
- Use Namespaces: Group translations into different JSON files to keep your project organized
- Maintain Key Consistency: Use the same key structure across all language files
- Use Parameters: For text with variables, use parameters:
t('welcome', { name: 'John' })
- Use Plurals: next-intl supports plural forms, which can be used with
t('items', { count: 5 })