-
Notifications
You must be signed in to change notification settings - Fork 56
Closed
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
Replace the current /api/v2/languages API calls with the new languages.json file available in distribution CDN to improve SDK performance and reduce API load.
Current Implementation
The SDK currently fetches language information through:
- API Call:
CrowdinApi.getLanguagesInfo()→/api/v2/languages - Caching: Languages are cached via
DataManager.getSupportedLanguages() - Custom Languages: Uses
custom_languagesfield frommanifest.jsonwhich will be deprecated - Usage: Language info is used in multiple repositories:
StringDataRemoteRepository(lines 74, 84-85)TranslationDataRepository(lines 60, 72-73)RealTimeUpdateManager(line 63)
Proposed Solution
Utilize the new distribution file: https://distributions.crowdin.net/<hash>/languages.json
Benefits:
- ✅ Performance: No additional API calls needed
- ✅ Reduced API Load: Fewer requests to Crowdin platform
- ✅ Future-Proof: Removes dependency on deprecated
custom_languages - ✅ Consistency: Same data format as current List Languages API response
Implementation Strategy:
1. Add Distribution Languages API
Add new endpoint to CrowdinDistributionApi.kt:
@GET("/{distributionHash}/languages.json")
fun getLanguages(
@Path("distributionHash") distributionHash: String,
@Query("timestamp") timeStamp: Long
): Call<LanguagesInfo>2. Update Language Fetching Logic
- Modify
DataManager.getSupportedLanguages()to fetch from distribution instead of API - Update
CrowdingRepository.getSupportedLanguages()to use distribution endpoint - Implement timestamp-based validation using existing
SyncDatamechanism
3. Remove Custom Languages Dependency
Update language resolution in:
StringDataRemoteRepository.getSafeLanguageCode()TranslationDataRepository.onManifestDataReceived()Extensions.getMatchedCode()
4. Leverage Existing Caching
Use current timestamp-based caching strategy (already implemented in StringDataRemoteRepository):
- Compare
manifest.timestampwith cached timestamp - Cache remains valid if timestamp unchanged
- Extends TTL for unchanged data
Technical Details:
- Data Format: Same as current
LanguagesInfomodel (trimmed List Languages response) - Caching Key: Based on
manifest.timestamp(existing pattern) - Fallback: Maintain current API as fallback for backward compatibility during transition
- Testing: Update
TestCommon.ktto include languages.json test data
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed