twilio/voice: translate spoken call prompts via Twilio.VoiceLanguage - #4515
Open
Vr00mm wants to merge 1 commit into
Open
twilio/voice: translate spoken call prompts via Twilio.VoiceLanguage#4515Vr00mm wants to merge 1 commit into
Vr00mm wants to merge 1 commit into
Conversation
Twilio voice calls previously spoke hardcoded English regardless of the configured Twilio.VoiceLanguage, which only drove TTS pronunciation. This adds an i18n layer so the spoken prompts are translated to the configured language, falling back to English (text + en-US voice) when no translation is available. - voicemsg.go: x/text message catalog + language matcher; voicePrinter() resolves VoiceLanguage to a printer and the <Say> language attribute. - twiml.go/voice.go: route literal prompts through the printer (Sayf/sayT), while raw pre-built bodies stay untranslated (avoids %-format breakage). - 33 base-language translation files covering all 67 Twilio voice locales (regional variants resolve to their base via the matcher). - Guard tests: key-set completeness, fallback behaviour, multi-arg rendering. - Smoke test: voice alert + ack spoken in French via Twilio.VoiceLanguage. - Config description and generated mapconfig updated. Translations are machine-generated and should be reviewed. Signed-off-by: Rémi ZIOLKOWSKI <remi.ziolkowski@gmail.com>
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
Twilio voice calls currently speak hardcoded English regardless of the
configured
Twilio.VoiceLanguage— that setting only drives Polly TTSpronunciation, so e.g.
fr-FRreads English text with a French accent.This adds a small i18n layer (
golang.org/x/text/message) so the spoken callprompts are translated to the configured language, with English as the
fallback.
Behavior & compatibility
Twilio.VoiceLanguageempty (the default), output is byte-for-byte identicalto today: English text, no
languageattribute.regional variants resolve to their base (
fr-CA→fr,pt-BR/pt-PT→pt,cmn-CN/cmn-TW→zh, allen-*→ English).spoken with an
en-USvoice (so text and voice stay consistent).clearing the config value.
What's included
notification/twilio/voicemsg.go: catalog + language matcher;voicePrinter()resolves
VoiceLanguageto a printer and the<Say>language attribute.twiml.go/voice.go: literal prompts routed through the printer(
Sayf/sayT); raw pre-built bodies stay untranslated to avoid%-formatbreakage from user content (e.g. an alert summary containing
%).mapconfig.goupdated.Testing
golangci-lint(project version) clean on changed packages;go mod tidyand
gofmtclean;go generateleaves the tree clean.the canonical list), fallback behavior, and multi-argument rendering across
Latin and non-Latin scripts.
test/smoke/twiliovoicetranslated_test.go): withTwilio.VoiceLanguage=fr-FR, a voice alert and its acknowledgement areasserted to be spoken in French; existing English voice smoke tests still
pass.
The 33 translation files are machine-generated and would benefit from
review by native speakers before merge — the infrastructure and the English
default are the parts I'm confident about. Happy to split this into an
infrastructure-only PR (English + the i18n plumbing) and land languages
separately if that's preferred, or to open a tracking issue first per
CONTRIBUTING.
🤖 Generated with Claude Code