feat: Multi-provider translation service with auto-translation #25

Closed
opened 2026-04-09 13:52:33 +00:00 by KnallerKalle · 1 comment
KnallerKalle commented 2026-04-09 13:52:33 +00:00 (Migrated from github.com)

Summary

Implemented a transformer-based translation service using DeepL (primary) + MyMemory (fallback) to automatically translate all UI strings.

What Was Done

Translation Service (src/lib/translationService.ts)

  • Multi-provider architecture with automatic fallback
  • DeepL API: Best quality for European languages (DE, EN, FR)
  • MyMemory API: Free fallback covering all languages (RU, HE)
  • Translation caching with 7-day TTL in localStorage
  • Batch translation with rate limiting
  • Runtime translation for dynamic content

Translation Script (scripts/translate-messages.ts)

  • Auto-fills missing i18n keys from English source
  • npx tsx scripts/translate-messages.ts — Fill all missing keys
  • --dry-run flag for preview mode
  • --lang=fr for single language
  • Optional DEEPL_API_KEY env var for better quality

Results

Language Before After Translated
FR 265 keys 337 keys +72
HE 265 keys 337 keys +72
RU 254 keys 337 keys +83
Total 227 keys

Verified

  • ✅ All 5 languages render correctly in browser
  • ✅ Build passes with zero errors
  • ✅ 27/27 tests passing
  • ✅ Settings, Library, Tags, Generate pages fully translated

Usage

Auto-translate missing keys

npx tsx scripts/translate-messages.ts

With DeepL (better quality)

DEEPL_API_KEY=your_key npx tsx scripts/translate-messages.ts

Runtime translation in code

import { getTranslationService } from "@/lib/translationService";
const service = getTranslationService();
const result = await service.translate("Hello", "en", "fr");
## Summary Implemented a transformer-based translation service using DeepL (primary) + MyMemory (fallback) to automatically translate all UI strings. ## What Was Done ### Translation Service (`src/lib/translationService.ts`) - Multi-provider architecture with automatic fallback - DeepL API: Best quality for European languages (DE, EN, FR) - MyMemory API: Free fallback covering all languages (RU, HE) - Translation caching with 7-day TTL in localStorage - Batch translation with rate limiting - Runtime translation for dynamic content ### Translation Script (`scripts/translate-messages.ts`) - Auto-fills missing i18n keys from English source - `npx tsx scripts/translate-messages.ts` — Fill all missing keys - `--dry-run` flag for preview mode - `--lang=fr` for single language - Optional `DEEPL_API_KEY` env var for better quality ### Results | Language | Before | After | Translated | |----------|--------|-------|------------| | FR | 265 keys | 337 keys | +72 | | HE | 265 keys | 337 keys | +72 | | RU | 254 keys | 337 keys | +83 | | **Total** | | | **227 keys** | ### Verified - ✅ All 5 languages render correctly in browser - ✅ Build passes with zero errors - ✅ 27/27 tests passing - ✅ Settings, Library, Tags, Generate pages fully translated ## Usage ### Auto-translate missing keys ```bash npx tsx scripts/translate-messages.ts ``` ### With DeepL (better quality) ```bash DEEPL_API_KEY=your_key npx tsx scripts/translate-messages.ts ``` ### Runtime translation in code ```typescript import { getTranslationService } from "@/lib/translationService"; const service = getTranslationService(); const result = await service.translate("Hello", "en", "fr"); ```
KnallerKalle commented 2026-04-09 13:55:13 +00:00 (Migrated from github.com)

✅ Implemented in commit e503839

All 5 languages verified working in browser. Translation service + script ready for future use.

## ✅ Implemented in commit `e503839` All 5 languages verified working in browser. Translation service + script ready for future use.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Kalle/ATM#25
No description provided.