Translation Guide
This guide explains how to use and extend Ever Works' multilingual translation system powered by next-intl.
Supported Languagesโ
Ever Works supports 13+ languages out of the box:
| Language | Code | Flag |
|---|---|---|
| ๐ฌ๐ง English | en | Default |
| ๐ซ๐ท French | fr | |
| ๐ช๐ธ Spanish | es | |
| ๐ฉ๐ช German | de | |
| ๐จ๐ณ Chinese | zh | |
| ๐ธ๐ฆ Arabic | ar | RTL support |
| ๐ฎ๐น Italian | it | |
| ๐ต๐น Portuguese | pt | |
| ๐ฏ๐ต Japanese | ja | |
| ๐ฐ๐ท Korean | ko | |
| ๐ท๐บ Russian | ru | |
| ๐ณ๐ฑ Dutch | nl | |
| ๐ต๐ฑ Polish | pl |
Usageโ
In React Componentsโ
import { useTranslations } from 'next-intl';
export function MyComponent() {
const t = useTranslations('help'); // 'help' is the namespace
return (
<div>
<h1>{t('PAGE_TITLE')}</h1>
<p>{t('PAGE_SUBTITLE')}</p>
</div>
);
}
Translation File Structureโ
Translation files are located in the /messages folder:
messages/
โโโ en.json # English (default)
โโโ fr.json # French
โโโ es.json # Spanish
โโโ de.json # German
โโโ zh.json # Chinese
โโโ ar.json # Arabic
โโโ ... # Other languages
JSON Formatโ
{
"help": {
"PAGE_TITLE": "Help Center",
"PAGE_SUBTITLE": "Complete guide to using Ever Works",
"SECTION": {
"NESTED_KEY": "Nested translation"
}
}
}
Adding New Translationsโ
Step 1: Add Keys in Englishโ
Open messages/en.json and add your new keys:
{
"help": {
// ... existing translations ...
"NEW_SECTION_TITLE": "New Section",
"NEW_SECTION_DESC": "Description of the new section"
}
}
Step 2: Translate to Other Languagesโ
French (messages/fr.json)โ
{
"help": {
"NEW_SECTION_TITLE": "Nouvelle Section",
"NEW_SECTION_DESC": "Description de la nouvelle section"
}
}
Spanish (messages/es.json)โ
{
"help": {
"NEW_SECTION_TITLE": "Nueva Secciรณn",
"NEW_SECTION_DESC": "Descripciรณn de la nueva secciรณn"
}
}
Translation Namespacesโ
Common (common)โ
- Navigation elements
- Common actions (save, cancel, delete)
- General messages
Auth (auth)โ
- Login and registration
- Password management
- Authentication errors
Help (help)โ
- Help center content
- FAQ sections
- Support information
Pricing (pricing)โ
- Pricing plans
- Feature lists
- Billing information
Submit (submit)โ
- Form labels and placeholders
- Validation messages
- Success/error messages
Best Practicesโ
1. Naming Conventionsโ
Use descriptive, uppercase keys with underscores:
{
// โ
Good
"FAQ_SETUP_TIME": "How long does setup take?",
"FORM_ERROR_EMAIL": "Invalid email address",
// โ Bad
"FAQ_1": "How long does setup take?",
"ERROR1": "Invalid email address"
}
2. Placeholders and Variablesโ
{
"WELCOME_MESSAGE": "Welcome {name}!",
"ITEMS_COUNT": "You have {count} items"
}
Usage:
t('WELCOME_MESSAGE', { name: 'John' })
t('ITEMS_COUNT', { count: 5 })
3. Pluralizationโ
{
"ITEMS": {
"zero": "No items",
"one": "1 item",
"other": "{count} items"
}
}
Usage:
t('ITEMS', { count: 0 }) // "No items"
t('ITEMS', { count: 1 }) // "1 item"
t('ITEMS', { count: 5 }) // "5 items"
4. Rich Text Formattingโ
{
"TERMS": "By signing up, you agree to our <link>Terms of Service</link>"
}
Usage:
t.rich('TERMS', {
link: (chunks) => <Link href="/terms">{chunks}</Link>
})
Adding a New Languageโ
Step 1: Create Message Fileโ
# Copy English file as template
cp messages/en.json messages/it.json # Example for Italian
Step 2: Update Configurationโ
In i18n/routing.ts:
export const routing = defineRouting({
locales: ['en', 'fr', 'es', 'de', 'zh', 'ar', 'it'], // Add 'it'
defaultLocale: 'en',
localePrefix: 'as-needed'
});
Step 3: Add Flag Iconโ
Place the SVG file in /public/flags/it.svg
Step 4: Translate Contentโ
Translate all keys in messages/it.json to Italian
Step 5: Testโ
# Start dev server
npm run dev
# Visit the new locale
http://localhost:3000/it
Checking Missing Translationsโ
Verification Scriptโ
# Compare keys between English and French
diff <(jq -r 'paths(scalars) as $p | $p | join(".")' messages/en.json | sort) \
<(jq -r 'paths(scalars) as $p | $p | join(".")' messages/fr.json | sort)
Recommended Toolsโ
- i18n Ally - VS Code extension for managing translations
- BabelEdit - Visual translation editor
- Crowdin - Collaborative translation platform
RTL Support (Arabic)โ
Ever Works includes built-in RTL (Right-to-Left) support for Arabic:
// Automatically applied based on locale
<html dir={locale === 'ar' ? 'rtl' : 'ltr'}>
Testing RTLโ
- Switch to Arabic locale
- Verify layout mirrors correctly
- Check text alignment
- Test navigation and forms
Translation Checklistโ
When adding new features with text:
- Add keys in English (
en.json) - Translate to French (
fr.json) - Translate to Spanish (
es.json) - Translate to German (
de.json) - Translate to Chinese (
zh.json) - Translate to Arabic (
ar.json) - Translate to other supported languages
- Test in all languages
- Check RTL for Arabic
- Document new keys
Troubleshootingโ
Missing Translation Warningโ
Issue: Console shows "Missing translation" warning
Solution: Add the missing key to all language files
// Add to all messages/*.json files
{
"namespace": {
"MISSING_KEY": "Translation text"
}
}
Translation Not Updatingโ
Issue: Changes to translation files not reflecting
Solution: Restart the development server
# Stop the server (Ctrl+C)
# Start again
npm run dev
Locale Not Switchingโ
Issue: Language switcher doesn't change locale
Solution: Verify routing configuration
// Check i18n/routing.ts
export const routing = defineRouting({
locales: ['en', 'fr', 'es', ...], // Ensure locale is listed
defaultLocale: 'en'
});
Professional Translation Servicesโ
For legal or sensitive content, consider professional services:
- DeepL - High-quality AI translation
- Gengo - Professional human translators
- Smartling - Enterprise translation platform
Contributing Translationsโ
To contribute translations:
- Fork the repository
- Create a branch:
git checkout -b translation/my-language - Add/modify translations in
messages/ - Test thoroughly
- Submit a Pull Request
Next Stepsโ
- Internationalization Overview - Learn about i18n architecture
- Customization - Customize your directory
- Development - Set up development environment