methods/utils/translation_languages library

Central Language Definitions for Translation Pipeline (Frontend)

This module provides a single source of truth for all supported languages, language codes, and voice configurations across the Flutter application.

Language Code Standards:

  • ISO 639-1: 2-letter codes (e.g., 'en', 'es') - PRIMARY STANDARD
  • ISO 639-2: 3-letter codes (e.g., 'eng', 'spa') - for extended languages
  • BCP 47: Language tags with regions (e.g., 'en-US', 'pt-BR')

Classes

LanguageMetadata
Language metadata with display names and additional info
LanguageOption
Language option for dropdowns
SocketVoiceResponse
Result from socket voice fetch
TranslationLanguageEntry
Language entry with voice config override
TranslationVoiceConfig
Voice configuration for translation
VoiceCloneConfig
Voice clone configuration
VoiceOption
Voice option for TTS

Enums

LanguageRegion
Language region classification
TTSProvider
Supported TTS providers
TTSSupport
TTS support level
VoiceGender
Voice gender type

Constants

azureNeuralVoices → const Map<String, Map<String, List<String>>>
Azure Neural Voice mappings by language and gender
deepgramVoices → const Map<String, List<Map<String, String>>>
Deepgram Aura voice IDs
defaultVoiceGenders → const Map<String, VoiceGender>
Default voice gender per language
elevenLabsVoices → const Map<String, List<Map<String, String>>>
ElevenLabs pre-made voice IDs
languageMetadata → const Map<String, LanguageMetadata>
Language metadata with display names and additional info
openAIVoices → const Map<String, List<Map<String, String>>>
OpenAI TTS voice IDs
supportedLanguageCodes → const List<String>
Complete list of supported language codes (ISO 639-1 primarily)

Functions

fetchLanguagesViaSocket(Socket socket, {String displayLocale = 'en'}) Future<List<LanguageOption>>
Fetch supported languages via socket
fetchVoicesViaSocket(Socket socket, String provider, String language) Future<SocketVoiceResponse>
Fetch voices via socket connection (keeps API keys server-side)
getAvailableVoices(String langCode, {String provider = 'deepgram'}) Map<String, List<VoiceOption>>
Get all available voices for a language
getDefaultVoice(String langCode, {VoiceGender gender = VoiceGender.female, String provider = 'deepgram'}) String?
Get default voice for a language and gender
getDefaultVoiceGender(String langCode) VoiceGender
Get the default voice gender for a language
getLanguageName(String code, {String displayLocale = 'en'}) String
Get language display name
getLanguageNativeName(String code) String
Get native language name
getLanguagesByRegion(LanguageRegion region) List<LanguageOption>
Get languages by region
getLanguagesWithGoodTTS() List<LanguageOption>
Get languages with good TTS support
getSupportedLanguages({String displayLocale = 'en'}) List<LanguageOption>
Get all supported languages as list of LanguageOption
isLanguageSupported(String code) bool
Check if a language code is supported
isValidLanguageCode(String code) bool
Validate a language code format
normalizeLanguageCode(String code) String
Normalize a language code to ISO 639-1 (2-letter) format