You're absolutely right — this is a critical insight that simplifies the entire architecture dramatically.
Since translations are small (~10–100 KB per language), we can afford to:
- Load all translations for a language at once
- Eliminate complex scanning or runtime key collection
- Avoid real-time push systems like WebSockets or SSE (which are hard to scale and unreliable during outages)
✅ Final Design: Simple, Scalable, and Performant
🔑 Core Principles
| Principle | Why It Matters |
|---|
| Load all translations up front | Small size makes it trivial to load everything in one go |
| Engineers write English; translators get all text | Separation of concerns preserved |
| No runtime translation fetching | No latency, no complexity |
| Translations are versioned and cached | Fast delivery via CDN |
| Translators see instant changes in preview mode | Real-time editing without pushing to prod |
🧱 Architecture Overview
[Web Engineer] → [T("key", "English text")]
↓
[Build Process] → [All T() strings collected]
↓
[Translation DB] ↔ [Translator Dashboard]
↓
[Bundles Generated] → [en.json, fr.json, es.json...]
↓
[CDN + Browser Cache] → [Fast load for users]
🛠️ Key Components
1. T() Function – Just a Lookup
// In your code:
<div>{ T("welcome_message", "Welcome to Airbnb") }</div>
// Implementation:
function T(key, defaultText) {
return window.__TRANSLATIONS__[key] || defaultText;
}
✅ Engineers write in English, wrap with T()
✅ Translations are loaded ahead of time
✅ No network requests during rendering
2. Build-Time Translation Extraction
Use static analysis to extract all strings wrapped in T():
# During CI/CD build
npx extract-translations --input src/ --output public/translations/en.json
Example output (en.json):
{
"welcome_message": "Welcome to Airbnb",
"search_placeholder": "Where are you going?",
"submit_button": "Submit"
}
This file becomes the source of truth for all translatable strings.
3. Translation Database
Store all keys and their translations:
| key | en | fr | es |
|---|
| welcome_message | Welcome to Airbnb | Bienvenue sur Airbnb | Bienvenido a Airbnb |
| submit_button | Submit | Envoyer | Enviar |
- Translators use a dashboard to edit values directly in this table.
- Each language has its own JSON bundle generated from this data.
4. Bundle Generation
At deploy time, generate one file per language:
# Output files
public/translations/en.json
public/translations/fr.json
public/translations/es.json
...
Each file contains all translations for that language:
{
"welcome_message": "Bienvenue sur Airbnb",
"search_placeholder": "Où allez-vous ?",
"submit_button": "Envoyer"
}
These files are:
- Versioned (e.g.,
/translations/fr-v2345.json)
- Served via CDN
- Aggressively cached
5. User Experience Flow
- User visits site
- Server detects language (via cookie, URL param, or browser headers)
- Loads the appropriate translation bundle before React bootstraps:
<script>
fetch('/translations/fr.json')
.then(res => res.json())
.then(translations => {
window.__TRANSLATIONS__ = translations;
});
</script>
Or better yet, inline critical translations in HTML:
<script>
window.__TRANSLATIONS__ = {
"welcome_message": "Bienvenue sur Airbnb",
"search_placeholder": "Où allez-vous ?"
};
</script>
Then asynchronously load the rest:
<script src="/translations/fr.json" async onload="mergeTranslations(this)"></script>
6. Translator Workflow
Translator Dashboard Features:
- List of all translation keys
- Search/filter by key or status
- Edit any translation live
- See a preview of the page using that translation
When a translator updates a field:
- Update shown immediately in preview iframe
- Save to database
- On next deploy, updated translations included in new bundles
✅ No need for WS/SSE — translators see changes instantly in preview
✅ When offline, no missed updates — changes saved on reconnect
✅ Preview uses latest translations even before deploy
⚙️ Deployment Strategy
Option A: Full Bundle Deploy
- All translations bundled at deploy time
- CDN caches them aggressively
- Changes only visible after redeploy
Best for stable content.
Option B: Dynamic Bundle Service (Optional)
If you want real-time updates in production (rare):
GET /translations/fr.json?version=latest
Still fast because:
- Caches at CDN edge
- Only ~100 KB to transfer
- No per-key fetching needed
📈 Scaling Considerations
- Latency: <100ms to download full bundle
- Cacheability: Entirely cacheable via CDN
- Versioning: Use cache-busting URLs if needed
- Size: 100 KB is negligible even on mobile
- Fallback: If translation fails, show English default
👨💻 Developer Experience
- Engineers keep writing in English
- Wrap strings with
T("key", "default text")
- No need to worry about missing translations
- No runtime translation logic or scanning
🧪 Edge Cases
Missing Translation?
T("missing_key", "Default Text")
// Falls back to English string provided by engineer
New String Added?
- Extracted at build time
- Shows up in dashboard
- Translators translate when available
What About Plurals, Dates, Gender?
Use ICU MessageFormat:
T("listing_count", "{count, plural, one {# listing} other {# listings}}")
And store translated ICU strings in the database:
{
"listing_count": "{count, plural, one {# logement} other {# logements}}"
}
Parse with libraries like @formatjs/icu-matcher.
✅ Summary
| Component | Solution |
|---|
| Engineers | Write in English with T("key", "default text") |
| Translators | Edit all translations in dashboard |
| App Servers | Serve pre-built translation bundles |
| Users | Get translations upfront, zero runtime delay |
| Latency | Minimal – all translations loaded once |
| Scalability | Easy – small bundles, CDN-friendly |
| Real-time Updates | For translators only – in preview iframe |
💡 Bonus: Language Switcher UX
Let users switch languages instantly:
function setLanguage(langCode) {
fetch(`/translations/${langCode}.json`)
.then(res => res.json())
.then(translations => {
window.__TRANSLATIONS__ = translations;
reRenderApp(); // or refresh page
});
}
🎯 Conclusion
By leveraging the small size of translation data, we simplify the system dramatically:
- No scanning, no runtime key collection
- No per-page translation fetching
- No complex real-time sync (WS/SSE)
- Engineers write English, translators work independently
- Everything loads fast and scales globally
This is a clean, modern, scalable i18n architecture for large websites like Airbnb.