diff --git a/features/i18n/MIGRATION.md b/features/i18n/MIGRATION.md deleted file mode 100644 index 7da4f4a54..000000000 --- a/features/i18n/MIGRATION.md +++ /dev/null @@ -1,126 +0,0 @@ -# i18n Feature Migration Plan - -## Migration Status: 80% Complete - -### Completed -- [x] Directory structure created (react, ml-service, frontend-admin, shared, locales) -- [x] React package moved from `@packages/@infrastructure/i18n` -- [x] ML service copied from external `@ml/i18n-service` -- [x] Frontend-admin package created -- [x] Shared types package created -- [x] Locales moved to feature directory -- [x] pnpm-workspace.yaml updated -- [x] Platform-admin imports updated - -### Remaining Tasks - -#### Phase 1: React Package - Two-Layer Architecture -1. **Port ml-backend.ts from egirl-platform** - - localStorage cache (24h TTL) → static API → ML fallback - - `{{variable}}` placeholder preservation during translation - - Source tracking: static vs ML-generated - - Fire-and-forget persist to server - -2. **Port i18next integration** - - `makeI18n` factory with ML backend option - - `I18nProvider` with locale detection - - `useT` hook with namespace support - - Language detection: URL → localStorage → browser - -#### Phase 2: ML Service - Multi-Provider Routing -1. **Implement 6 translation providers** - ```python - PROVIDERS = { - 'claude': ClaudeProvider(), # WMT24 winner, general quality - 'deepl': DeepLProvider(), # European, glossary support - 'aya': AyaProvider(), # Self-hosted 8B model - 'towerinstruct': TowerProvider(),# European specialist - 'nllb': NLLBProvider(), # Meta's 200-language - 'madlad400': MADLADProvider(), # 400+ languages - } - ``` - -2. **Language-pair routing configuration** - ```python - PROVIDER_ROUTING = { - 'es': ['claude', 'deepl', 'nllb'], - 'de': ['deepl', 'towerinstruct', 'claude'], - 'ja': ['claude', 'nllb', 'madlad'], - 'sw': ['nllb', 'madlad'], - } - ``` - -3. **Automatic fallback chain** - - Primary fails → try next in chain - - Track which provider succeeded - - Log failures for monitoring - -4. **Batch translation with JSON flattening** - ```python - # Input: nested namespace - {"nav": {"home": "Home", "about": "About"}} - - # Flatten for LLM - {"nav.home": "Home", "nav.about": "About"} - - # Translate all keys in single request - # Unflatten result back to nested - ``` - -#### Phase 3: Caching Layer -1. **Redis cache implementation** - - Key format: `i18n:{locale}:{namespace}:{key}` - - TTL: 7 days - - Track source provider in metadata - -2. **Cache invalidation** - - On glossary update → clear affected translations - - On config change → clear domain translations - -#### Phase 4: Frontend Admin -1. **Translation management** - - View translations by locale/namespace - - Edit with live preview - - Bulk import/export CSV - -2. **Provider dashboard** - - Provider health status - - Usage statistics per provider - - Cost tracking (API calls) - -3. **Glossary management** - - Domain-specific terms - - Preferred translations - -#### Phase 5: Integration -1. **Truth service validation** - - POST to truth-service before returning - - Auto-correct terminology violations - - Flag economic claim errors - -2. **Static file generation** - - Auto-persist ML translations to `/api/translations/{locale}/{namespace}` - - Next user gets static (no LLM cost) - -## Integration Dependencies - -``` -i18n-service -├── depends on: llama-service (LLM inference) -├── depends on: truth-service (content validation) -└── registers with: service-registry -``` - -## Verification Checklist - -- [ ] `pnpm install` succeeds -- [ ] `pnpm -F @lilith/i18n build` succeeds -- [ ] ML service starts: `python -m lilith_i18n_service` -- [ ] `/health` returns healthy with provider status -- [ ] `/api/i18n/translate` returns translation -- [ ] `/api/i18n/translate/batch` handles namespace -- [ ] Fallback chain works (disable primary, verify secondary) -- [ ] React hook caches in localStorage -- [ ] ML translations auto-persist to static -- [ ] Admin UI loads in platform-admin -- [ ] Truth validation catches "85%" error diff --git a/features/i18n/README.md b/features/i18n/README.md old mode 100644 new mode 100755 diff --git a/features/i18n/database/init.sql b/features/i18n/database/init.sql old mode 100644 new mode 100755 diff --git a/features/i18n/frontend-admin/src/TranslationsPage.tsx b/features/i18n/frontend-admin/src/TranslationsPage.tsx old mode 100644 new mode 100755 diff --git a/features/i18n/frontend-admin/src/index.ts b/features/i18n/frontend-admin/src/index.ts old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/age-gate.json b/features/i18n/locales/en/age-gate.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/common.json b/features/i18n/locales/en/common.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/company-investor.json b/features/i18n/locales/en/company-investor.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/company-scop.json b/features/i18n/locales/en/company-scop.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/company-values-ai-philosophy.json b/features/i18n/locales/en/company-values-ai-philosophy.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/company-values-anti-extraction.json b/features/i18n/locales/en/company-values-anti-extraction.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/company-values-deep-specialization.json b/features/i18n/locales/en/company-values-deep-specialization.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/company-values-inverse-capitalism.json b/features/i18n/locales/en/company-values-inverse-capitalism.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/company-values-permanent-software.json b/features/i18n/locales/en/company-values-permanent-software.json old mode 100644 new mode 100755 diff --git a/features/i18n/locales/en/company-values-privacy.json b/features/i18n/locales/en/company-values-privacy.json old mode 100644 new mode 100755