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

LanguageCapability
Ratings for one language on one provider stack.
LanguageCapabilityProviders
Provider ids for each stage, e.g. deepgram:nova-3, openai:gpt-4o-mini, fish:s2.1-pro.
LanguageCapabilityStack
A managed preset ('system' or 'demo') or a custom stack of provider ids from providerCapabilities.
LanguageMetadata
Language metadata with display names and additional info
LanguageOption
Language option for dropdowns
ListenerLanguageGroup<T>
A listener picker group with its languages.
ProviderCapabilities
Measured tiers per provider id, then language code. Used to rate custom provider stacks.
SocketVoiceResponse
Versioned provider-authoritative catalogue (voice-catalogue-v1).
TranslationLanguageEntry
Language entry with voice config override
TranslationVoiceConfig
Voice configuration for translation
VoiceCapability
Voice rating for one language on one text-to-speech provider.
VoiceCloneConfig
Voice clone configuration
VoiceOption
Voice option for TTS

Enums

CaptionTier
Quality of translated captions into the language.
LanguageRegion
Language region classification
ListenerGroup
Where a language belongs in a listener (translated language) picker.
SpeakerListing
Whether a language belongs in a speaker (spoken language) picker.
SpeakTier
Speech-to-text quality when the speaker sets the language.
TTSProvider
Supported TTS providers
TTSSupport
TTS support level
VoiceGender
Voice gender type
VoiceTier
Translated speech in the language.

Constants

autoDetectLanguages → const List<String>
Languages that automatic language detection recognises reliably (rated good or better).
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
languageCapabilitiesMeasuredAt → const String
languageCapabilityPresetStacks → const Map<String, LanguageCapabilityProviders>
Provider stacks behind the managed presets.
languageMetadata → const Map<String, LanguageMetadata>
Language metadata with display names and additional info
listenerGroupLabels → const Map<ListenerGroup, String>
listenerGroupNotes → const Map<ListenerGroup, String>
measuredLanguageCodes → const List<String>
Languages covered by the measurement, in table order.
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)

Properties

languageCapabilities → Map<String, Map<String, LanguageCapability>>
Ratings per managed preset ('system', 'demo'), then language code.
final
providerCapabilities → ProviderCapabilities
Measured tiers per provider id, then language code.
final

Functions

capabilityTtsSupport(LanguageCapability c) → TTSSupport
Legacy single rating derived from a capability (matches languageMetadata ttsSupport for the system preset).
emptyVoiceCatalogue() → Map<String, List<VoiceOption>>
fetchLanguagesViaSocket(Socket socket, {String displayLocale = 'en'}) → Future<List<LanguageOption>>
Fetch supported languages via socket
fetchVoicesViaSocket(Socket socket, String provider, String language, {String? roomName, Duration requestTimeout = const Duration(seconds: 20)}) → Future<SocketVoiceResponse>
Optional named arguments preserve existing callers; room-aware callers must include their joined room. Provider is only a compatibility hint, not authority.
filterSpeakerLanguages<T>(List<T> languages, String codeOf(T), [LanguageCapabilityStack stack = const LanguageCapabilityStack.system()]) → List<MapEntry<T, SpeakerListing>>
Speaker listing for each language that transcribes well enough to list (SpeakerListing.yes or SpeakerListing.beta); languages outside the measurement are marked beta.
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
getLanguageCapability(String code, [LanguageCapabilityStack stack = const LanguageCapabilityStack.system()]) → LanguageCapability
Rating for a language on a managed preset (system by default) or on a custom provider stack. For a custom stack, each stage uses the measured provider when known and the system preset otherwise. An optional llmFallback supplies captions where the main LLM is below good and the fallback is good.
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
groupListenerLanguages<T>(List<T> languages, String codeOf(T), [LanguageCapabilityStack stack = const LanguageCapabilityStack.system()]) → List<ListenerLanguageGroup<T>>
Groups listener languages in display order: natural voice, captions + basic voice, captions only, then preview. Languages without usable captions are left out; languages outside the measurement go to preview.
isLanguageMeasured(String code) → bool
True when the language was part of the measurement.
isLanguageSupported(String code) → bool
Check if a language code is supported
isValidLanguageCode(String code) → bool
Validate a language code format
listenerGroup(LanguageCapability c) → ListenerGroup
Where a language belongs in a listener (translated language) picker.
normalizeLanguageCode(String code) → String
Normalize a language code to ISO 639-1 (2-letter) format
parseVoiceCatalogue(dynamic response, String language) → SocketVoiceResponse
Invalid responses never authorize a guessed provider or static voice ID.
speakerListing(LanguageCapability c) → SpeakerListing
Whether a language belongs in a speaker picker; SpeakerListing.beta languages are listed with a label.
supportsAutoDetect(String code) → bool
True when automatic language detection recognises this language reliably.