Auto-generated translation updates from the English source file (`web/src/locales/languages/en.json`). 🤖 Generated with automated translation workflow Co-authored-by: oasisk <35160958+oasisk@users.noreply.github.com> Co-authored-by: Hengfei Yang <hengfei.yang@gmail.com>
Translation Management
Automated translation system for OpenObserve using AWS Translate.
Overview
This system automatically translates the English locale file (en.json) into multiple languages during the build process. It intelligently preserves existing translations and only translates new keys, making it safe to run repeatedly.
🚀 How It Works
Automatic workflow triggered by en.json changes:
- Developer updates
en.jsonand pushes to any branch (main, develop, feature branches) - GitHub Action detects the change and automatically triggers
- Translation script runs using AWS Translate to update all language files
- Changes are committed back to the same branch automatically
- Build workflows use updated files - all subsequent builds have fresh translations
This means translations are always up-to-date without any manual intervention!
Supported Languages
- 🇹🇷 Turkish (tr)
- 🇨🇳 Chinese (zh)
- 🇫🇷 French (fr)
- 🇪🇸 Spanish (es)
- 🇩🇪 German (de)
- 🇮🇹 Italian (it)
- 🇵🇹 Portuguese (pt)
- 🇯🇵 Japanese (ja)
- 🇰🇷 Korean (ko)
- 🇳🇱 Dutch (nl)
How It Works
- Source File: All translations originate from
web/src/locales/languages/en.json - Translation: New keys are automatically translated using AWS Translate
- Preservation: Existing translations are never overwritten
- Nested Support: Handles nested JSON structures correctly
Local Development
Prerequisites
- Python 3.11+
- AWS Credentials with access to AWS Translate service
- AWS CLI configured or environment variables set
Setup
# From the web directory
npm run translate:setup
Or manually:
cd scripts/translations
pip3 install -r requirements.txt
Configure AWS Credentials for Local Development
Option 1 - AWS CLI (recommended):
aws configure
Option 2 - IAM Role (if running on EC2/ECS):
# Uses instance profile automatically
# No configuration needed
Option 3 - Environment variables:
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_DEFAULT_REGION=us-east-1
Option 4 - Assume IAM Role locally:
aws sts assume-role \
--role-arn arn:aws:iam::ACCOUNT_ID:role/GitHubActions-TranslationRole \
--role-session-name local-translation
# Then export the credentials from the output
Note: GitHub Actions uses OIDC and assumes the IAM role automatically. Local development can use any of the above methods.
Running Translations
Translate all languages:
# From the web directory
npm run translate
# Or directly
cd scripts/translations
python3 main.py
Translate specific languages:
cd scripts/translations
python3 main.py fr es de
GitHub Actions Workflow
Automatic Translation Updates
The workflow (.github/workflows/update-translations.yml) automatically runs when:
- Trigger: Any push that modifies
web/src/locales/languages/en.json - Branches: All branches (
**) - Action:
- Runs Python translation script
- Updates all language JSON files
- Commits changes back to the same branch
- Subsequent builds use the updated files
Setup Requirements
The workflow uses IAM Role with OIDC for secure, credential-less authentication.
IAM Role Configuration
The workflow assumes an IAM role via OIDC. The role ARN is not hardcoded — it
is read from the AWS_TRANSLATE_ROLE_ARN repository secret so the AWS account ID
is not exposed in source control:
- IAM Role: stored in the
AWS_TRANSLATE_ROLE_ARNsecret - Region:
us-east-1
You can point this secret at the same role used by other OpenObserve workflows
(e.g., build-pr-image.yml).
Required IAM Permissions
Ensure the GitHubActionsRole has the following permission for AWS Translate:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"translate:TranslateText"
],
"Resource": "*"
}
]
}
Note: If you need to add this permission, attach a policy to the existing
GitHubActionsRolein AWS IAM Console.
GitHub Repository Setup
Add one repository secret so the workflow can authenticate via OIDC without exposing the AWS account ID:
| Secret | Value |
|---|---|
AWS_TRANSLATE_ROLE_ARN |
arn:aws:iam::<ACCOUNT_ID>:role/<RoleName> |
Set it under Settings → Secrets and variables → Actions → New repository secret
(or via gh secret set AWS_TRANSLATE_ROLE_ARN). The workflow fails fast with a
clear error if this secret is missing. No long-lived AWS keys are stored — only
the role ARN, which is assumed via GitHub's OIDC provider.
Workflow Behavior
graph TD
A[Push Code to Branch] --> B[Update Translations Workflow]
B --> C{en.json Changed?}
C -->|Yes| D[Run Translation Script]
C -->|No| E[Skip Translation]
D --> F[Commit Updated Languages]
E --> G[Mark Complete]
F --> G
G --> H[Build Workflows Start]
H --> I[Build with Latest Translations]
Workflow Execution Order:
- Push code →
update-translations.ymlruns - Checks if
en.jsonchanged- If YES: Translates and commits back to branch
- If NO: Skips (fast, ~10 seconds)
- If translations were committed → New push event
- Build workflows trigger on the new commit → Use updated translations
Key Features:
- ✅ Always runs - Checks every push for en.json changes
- ✅ Smart detection - Only translates if en.json actually changed
- ✅ Non-blocking - Quick skip if no translation needed
- ✅ Auto-commit - Updates committed back to same branch
- ✅ Natural flow - Translation commit triggers builds automatically
- ✅ Works everywhere - All branches (main, develop, feature branches)
Manual Workflow Trigger
You can also run translations manually:
- Go to Actions tab in GitHub
- Select Update Translations workflow
- Click Run workflow
- (Optional) Specify specific languages:
fr es de - Translations will be committed to the current branch
File Structure
scripts/translations/
├── README.md # This file
├── main.py # Entry point for translation script
├── translator.py # Core translation logic
└── requirements.txt # Python dependencies
web/src/locales/languages/
├── en.json # Source file (English)
├── tr.json # Turkish translations
├── zh.json # Chinese translations
├── fr.json # French translations
├── es.json # Spanish translations
├── de.json # German translations
├── it.json # Italian translations
├── pt.json # Portuguese translations
├── ja.json # Japanese translations
├── ko.json # Korean translations
└── nl.json # Dutch translations
Adding New Languages
- Add language code to
get_supported_languages()intranslator.py - Update the README to reflect the new language
- Run the translation script
Troubleshooting
Workflow Not Detecting en.json Changes
Symptom: You changed en.json but workflow says "en.json not modified"
Solution 1 - Check workflow logs:
- Go to Actions → Update Translations → Click the run
- Look at "Check if en.json was modified" step
- It shows debug info: event type, before/after SHAs, and changed files
Solution 2 - Use force flag:
- Go to Actions → Update Translations
- Click Run workflow
- Check "Force translation even if en.json not detected as changed"
- Click Run workflow
Solution 3 - Debug detection:
# Locally check what git sees
git show --name-only --pretty="" HEAD
# Should show web/src/locales/languages/en.json
# Check last push
git diff HEAD~1 --name-only
Root cause: The detection uses git diff to compare commits. If:
- Multiple commits in one push → Uses
github.event.beforeandgithub.sha - First commit on branch → Uses
git show HEAD - Manual trigger → Uses
git show HEAD
AWS Credentials Error
ERROR: No credentials for the translation service.
Solution: IAM role should be automatically assumed via OIDC. Check:
- Workflow has
permissions: id-token: write - The
AWS_TRANSLATE_ROLE_ARNsecret is set and points to a valid role - Role has
translate:TranslateTextpermission
Import Error
ModuleNotFoundError: No module named 'boto3'
Solution: Run npm run translate:setup or pip3 install -r requirements.txt
Translation Quality Issues
- Machine translations are not perfect
- Review translations before merging PRs
- Consider manual review for critical UI text
- Native speakers should review translations
Build Has Old Translations
Symptom: Build doesn't have the latest translations
Solution: Check if translation workflow ran and committed:
- Go to Actions → Find the Update Translations run
- Check if it detected en.json changes and committed translations
- If translations were committed, the commit should trigger a new build
- The new build will have updated translations
Workflow Example
Scenario: Adding New UI Text
-
Developer adds new text to
en.json:{ "dashboard": { "newFeature": "This is a new feature" } } -
Merge the
en.jsonchange tomain:git add web/src/locales/languages/en.json git commit -m "feat: add new dashboard feature text" # open a PR and merge to main -
Workflow automatically (on
mainonly):- Triggers because
web/src/locales/languages/en.jsonchanged - Runs translation script
- Translates only the new or modified keys to all 10 languages
- Commits updated
fr.json,es.json, etc. plus.translation_state.json
- Triggers because
-
Build workflows:
- Use the newly updated translation files
- No additional steps needed
Why
mainonly? Running on every feature branch made AWS Translate bill for the same strings repeatedly (per branch, per rebase, again on merge). Gating tomaintranslates each string once, when it actually lands.
Change detection (.translation_state.json)
scripts/translations/.translation_state.json records, per locale, a hash of the
English source each translated value was derived from. On every run the script:
- Translates a key only when it is new, missing in a target file, or its English source text changed since the last run (so editing an existing label re-translates it).
- Keeps already-translated text whose source is unchanged — it is never re-sent to AWS, and English is never "translated" to English.
- Prunes keys that were removed from
en.json. - Bootstraps safely: the first run after this file is introduced adopts existing translations as-is (no costly full re-translation, no overwriting manual fixes).
Commit .translation_state.json together with the translation files — it is the
source of truth that keeps subsequent runs incremental.
Best Practices
- Review Commits: Check auto-generated translation commits for accuracy
- Test in UI: Verify translations display correctly in the application
- Manual Fixes: Manual edits to a key are preserved until its English source changes
- Context Matters: Some terms may need manual translation for proper context
- Land on
main: Translations are generated whenen.jsonis merged tomain
Cost Considerations
AWS Translate pricing (as of 2024):
- $15 per million characters
Cost Per Workflow Run:
| Update Type | Characters | Languages | Total Chars | Cost |
|---|---|---|---|---|
| Small (10 strings) | 500 | 10 | 5,000 | $0.08 |
| Medium (50 strings) | 2,500 | 10 | 25,000 | $0.38 |
| Large (200 strings) | 10,000 | 10 | 100,000 | $1.50 |
| Full translation | 60,000 | 10 | 600,000 | $9.00 |
Monthly Estimates:
Active Development:
- 10-15
en.jsonupdates/month - Average 20 new strings per update
- Monthly cost: $0.80 - $1.20
Production:
- 5-8
en.jsonupdates/month - Average 15 new strings per update
- Monthly cost: $0.40 - $0.80
First-time full translation: ~$9 (one-time)
Cost Optimization:
- ✅ Only new or modified keys are translated (unchanged text is never re-sent)
- ✅ Runs on
mainonly, and only whenen.jsonchanges (no per-branch re-billing) - ✅ Superseded runs are cancelled (
concurrencywithcancel-in-progress) - ✅ Safety cap (
TRANSLATION_MAX_KEYS, default 5000) blocks accidental mass re-translation - ✅ Failed AWS calls are retried next run, not silently billed as English
- ✅ Typical monthly cost: Under $2
Alternative Translation Services
To use a different service, modify translator.py:
- Google Cloud Translate
- DeepL API
- Azure Translator
- OpenAI GPT-4 (for context-aware translations)
Support
For issues or questions:
- Check this README first
- Review existing GitHub issues
- Create a new issue with the
translationslabel