feat: Add offline translation cache and real-time language detection#78
Merged
phertyameen merged 1 commit intoApr 27, 2026
Merged
Conversation
## Summary This PR implements two key translation features as part of the Stellar Wave Program: ### Issue bridgelet-org#67: Add Offline Translation Cache for Recent Phrases - **Feature**: Offline translation caching system - **Location**: `mobile/app/src/storage/TranslationCache.ts` - **Capabilities**: - Cache recently translated phrases locally using AsyncStorage - Support configurable TTL (Time-to-Live) with default 7-day expiry - Automatic cleanup of expired entries - Duplicate prevention with unique ID generation - Maximum cache size management (default 100 entries) - Methods to retrieve single translations, all translations, or by language pair ### Issue bridgelet-org#66: Implement Real-Time Language Detection in Chat Input - **Feature**: Real-time language detection with debouncing - **Components**: 1. `mobile/app/src/features/translate/languageDetection.ts` - Language detection service 2. `mobile/app/src/hooks/useLanguageDetection.ts` - React hook for language detection 3. `mobile/app/src/components/LanguageInput.tsx` - UI component with built-in detection - **Capabilities**: - Automatic language detection while typing - Debounced API calls (300ms) to prevent excessive requests - Fallback detection using Unicode pattern matching when API is unavailable - Manual language override with dropdown selection - Display of detection confidence percentage - Alternative language suggestions - Proper React component with typed props ## Technical Details ### TranslationCache - Uses AsyncStorage for non-sensitive persistent storage - Implements LRU-like behavior with timestamp tracking - Automatic expiration cleanup - Configurable via CacheConfig interface ### LanguageDetection - Supports 12+ languages (en, es, fr, de, it, pt, ru, ar, zh, ja, ko, hi) - 0.6 confidence threshold for auto-detection - Pattern-based fallback for offline scenarios - Debounce prevents excessive API calls ### LanguageInput Component - Forward ref support for direct input access - Integrated detection badge showing language and confidence - Manual override dropdown - Alternative suggestions when available - Styled for React Native with TouchableOpacity controls - Configurable via props (placeholder, multiline, etc.) ## Testing Notes - All features include proper error handling - Console logging for debugging - Type-safe implementations with full TypeScript support - Compatible with React Native Expo setup --- Closes bridgelet-org#67 Closes bridgelet-org#66
|
@a-malik-gh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
phertyameen
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements two key translation features as part of the Stellar Wave Program:
Issue #67: Add Offline Translation Cache for Recent Phrases
mobile/app/src/storage/TranslationCache.tsIssue #66: Implement Real-Time Language Detection in Chat Input
Feature: Real-time language detection with debouncing
Components:
mobile/app/src/features/translate/languageDetection.ts- Language detection servicemobile/app/src/hooks/useLanguageDetection.ts- React hook for language detectionmobile/app/src/components/LanguageInput.tsx- UI component with built-in detectionCapabilities:
Technical Details
TranslationCache
LanguageDetection
LanguageInput Component
Testing Notes
Closes #67 Closes #66
Executive Summary
Linked Issues & References
Type of Change
Category
Domain
Technical Implementation Details
Breaking Changes
Verification & Testing Strategy
Automated Tests
Manual Verification
1. Environment:
2. Reproduction Steps:
3. Proof of Execution:
Quality Assurance Checklist
By submitting this Pull Request, I acknowledge that I have adhered to the Bridgelet contribution guidelines.