Google Translate Integration for dotCMS
Native integration that enables automatic content translation across language versions through workflow automation, powered by the Google Cloud Translation API.
What It Does#
The Google Translate integration in dotCMS automatically translates content from one language into all other configured language versions in your instance. When a content editor triggers a workflow action with the "Translate Content" sub-action, dotCMS sends the translatable text fields to the Google Translation API and creates translated copies of the content in each target language.
Key capabilities:
- One-click translation to all installed languages or specific language codes
- Translates Text, WYSIWYG, and Textarea fields automatically
- Binary fields and Tags are copied as-is to translated versions
- API key configurable per-site via Apps or globally via config property
- Recursive translation protection (translated content won't re-trigger translation)
- Source content publish state is preserved in translated versions
What it does not do:
- Does not translate Binary fields, Tag fields, or Category fields
- Does not translate Block Editor fields by default (must be added manually)
- Does not auto-publish unless the source content was live
Prerequisites#
- dotCMS instance with multiple language versions installed
- Google Cloud Platform account with billing enabled
- Google Cloud Translation API enabled
- API Key from Google Cloud Console
Google Cloud Setup#
Step 1: Enable Cloud Translation API#
- Go to Google Cloud Console
- Select or create a project
- Go to APIs & Services → Library
- Search for "Cloud Translation API"
- Click Enable
Step 2: Create an API Key#
- Go to APIs & Services → Credentials
- Click Create Credentials → API Key
- Copy the generated API key
- (Recommended) Click Restrict Key:
- Under API restrictions, select Cloud Translation API
- Click Save
dotCMS Configuration#
Step 1: Install Language Versions#
The integration translates content into all installed languages. Make sure your target languages are configured:
- Go to Settings → Languages
- Click Add Language for each target language
- Save
Step 2: Configure the Google Translate App#
- Go to Settings → Apps
- Find Google Translation in the list
- Click to configure
- Select your site (or System Host for global configuration)
- Enter your Google Service API Key
- Click Save
API key resolution order:
- Value entered directly in the workflow sub-action parameters
- Apps configuration for the current site
- Apps configuration for System Host
GOOGLE_TRANSLATE_SERVICE_API_KEYproperty indotmarketing-config.properties
Step 3: Create the Translation Workflow#
- Go to Settings → Workflow Schemes
- Create or edit a workflow
- Add a workflow action (e.g., "Translate to All Languages")
- Add the Translate Content sub-action
- Configure the sub-action parameters:
| Parameter | Default | Description |
|---|---|---|
| Translate to | all | Target languages. Use all or specific codes: es,fr,de |
| Translate Field Types | text,wysiwyg,textarea | Field types to translate (comma-separated) |
| Ignore Fields | (empty) | Field variable names to exclude from translation |
| Service API Key | (empty) | Override the API key at workflow level (optional) |
- Important: Place the Translate Content sub-action after a Save sub-action. The source content must be persisted before translation runs.
Recommended sub-action order:
- Save Content
- Translate Content
- (Optional) Push Publish
Step 4: Assign Workflow to Content Type#
- Go to Content Types
- Select the content type to enable translation for
- Go to the Workflow tab
- Assign the workflow scheme containing your translation action
- Click Save
Usage#
Translating Content#
- Create or edit content in your primary language
- Fill in all fields
- Click Save (or use a Save action first)
- Click the workflow action button (e.g., "Translate to All Languages")
- dotCMS sends text fields to Google Translation API
- Translated content versions are created for each target language
- Switch the language selector in the content editor to view each translation
What Gets Translated#
| Field Type | Translated | Notes |
|---|---|---|
| Text | ✅ Yes | Default |
| WYSIWYG | ✅ Yes | Default |
| Textarea | ✅ Yes | Default |
| Block Editor | ❌ No | Must add block_editor to field types manually |
| Binary | ❌ No | Copied as-is from source |
| Tag | ❌ No | Copied as-is from source |
| Category | ❌ No | Copied as-is from source |
Including Block Editor Fields#
To include Block Editor fields, update the Translate Field Types parameter in the sub-action:
text,wysiwyg,textarea,block_editor
Targeting Specific Languages#
Instead of translating to all languages, specify language codes:
es,fr,de,pt
Language codes must match the language codes of installed language versions in your dotCMS instance.
Using Ignore Fields#
To exclude specific fields from translation, add their variable names to Ignore Fields:
internalNotes,seoMetadata,urlTitle
How It Works Under the Hood#
When the Translate Content sub-action runs:
- Validates source content is saved and retrievable
- Identifies translatable fields based on
fieldTypesandignoreFieldsparams - Resolves target languages from
translateToparam against installed languages (excludes source language) - Calls Google Translation API (
translation.googleapis.com/language/translate/v2) for each target language - Creates translated contentlets with translated text fields
- Copies binary files and tag values from source to each translated version
- Saves and optionally publishes translated versions (mirrors source content's live state)
- Unlocks the source contentlet
The integration uses the Google Translation REST API v2 directly via HTTP POST — not the Google Cloud SDK.
Troubleshooting#
"No API Key Found"#
Cause: No API key is configured anywhere in the resolution chain.
Solution:
- Go to Settings → Apps → Google Translation
- Add your API key for the site or System Host
- Save
"Content must be persisted first"#
Cause: The Translate Content sub-action ran before the content was saved.
Solution:
- In your workflow action, ensure a Save Content sub-action appears before Translate Content
"No Fields to translate"#
Cause: The Translate Field Types parameter doesn't match any fields in the content type.
Solution:
- Check the field types in your content type
- Update the
Translate Field Typesparameter to match (e.g., addwysiwygif that's the field type being used)
Translation not appearing for a language#
Cause: The language code in translateTo doesn't match an installed language.
Solution:
- Go to Settings → Languages and note the exact language codes installed
- Update the
translateToparameter to match
API quota or billing errors#
Cause: Google Cloud billing is not enabled, or the API quota has been exceeded.
Solution:
- Verify billing is enabled in Google Cloud Console
- Check API usage under APIs & Services → Cloud Translation API → Quotas
Technical Details#
Code locations in dotCMS/core:
- Workflow Actionlet:
dotCMS/src/main/java/com/dotmarketing/portlets/workflows/actionlet/TranslationActionlet.java - Translation Service:
dotCMS/src/main/java/com/dotcms/translate/GoogleTranslationService.java - App Config:
dotCMS/src/main/resources/apps/dotGoogleTranslate-config.yml
API endpoint used:
POST https://translation.googleapis.com/language/translate/v2?key={apiKey}
Request payload:
{ "q": ["Text to translate"], "source": "en", "target": "es" }
Resources#
- dotCMS Documentation: Translate Content Sub-Action
- Google Cloud Translation API: Documentation
- Supported Languages: Language Support
- dotCMS Source: dotCMS/core on GitHub
Next Steps#
This guide will be used as the basis for:
- Google Translate integration page on dotcms.com
- Updated documentation on dev.dotcms.com/docs