gt-cli@2.9.0
Overview
The gt command-line interface (CLI) now supports Twilio Content JSON as a file format. If you use Twilio's Content Template Builder to send structured messages over WhatsApp, SMS, or RCS, you can now translate those templates using the same gt translate workflow you already use for your app.
Why this matters
Twilio Content Templates are JSON files that define structured messages -- text with variables, quick-reply buttons, cards with media and actions. These templates contain user-facing strings: button labels, body text, card titles. If you're sending messages in multiple languages, those strings need translating.
The current approach is to create a separate content template for each language manually through the Twilio Console or API. Each template gets its own SID, its own approval cycle, and its own maintenance burden. There's no single source of truth for what a message says across languages.
With this CLI update, you write the template once in your default language and let gt translate handle the rest.
Walkthrough
Say you're building a customer support flow over WhatsApp using Twilio. You have a quick-reply template that greets the user and offers three options:
{
"friendly_name": "support_greeting",
"language": "en",
"variables": { "1": "Customer" },
"types": {
"twilio/quick-reply": {
"body": "Hi, {{1}}. Thanks for contacting support. How can we help?",
"actions": [
{ "title": "Check order status", "id": "order_status" },
{ "title": "Return an item", "id": "return_item" },
{ "title": "Speak with an agent", "id": "speak_agent" }
]
},
"twilio/text": {
"body": "Hi, {{1}}. Thanks for contacting support. How can we help?"
}
}
}The body fields and title values in actions are all translatable strings. The {{1}} variable placeholder, the id fields, and the structural keys are not.
Step 1: Configure
Add twilioContentJson to your gt.config.json file:
{
"defaultLocale": "en",
"locales": ["en", "es", "fr", "ja"],
"files": {
"twilioContentJson": {
"include": ["twilio/[locale]/**/*.json"]
}
}
}The [locale] placeholder in the include path tells the CLI where to find source files and where to save translations. Source files are read from twilio/en/ and translated files are saved to twilio/es/, twilio/fr/, etc.
Step 2: Translate
npx gt@latest translateTranslations are generated for each configured locale. The output preserves the Twilio JSON structure -- only the string values change.
The Spanish output might look like:
{
"friendly_name": "support_greeting",
"language": "es",
"variables": { "1": "Customer" },
"types": {
"twilio/quick-reply": {
"body": "Hola, {{1}}. Gracias por contactar con soporte. ¿En qué podemos ayudarte?",
"actions": [
{ "title": "Ver estado del pedido", "id": "order_status" },
{ "title": "Devolver un artículo", "id": "return_item" },
{ "title": "Hablar con un agente", "id": "speak_agent" }
]
},
"twilio/text": {
"body": "Hola, {{1}}. Gracias por contactar con soporte. ¿En qué podemos ayudarte?"
}
}
}Each translated file is a valid Twilio Content JSON template that can be uploaded directly to the Twilio Content API as a new locale-specific template.