added workflow to udpate the language conversion --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Bhargav <BJP232004@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 is already configured to use:
- IAM Role:
arn:aws:iam::058694856476:role/GitHubActionsRole - Region:
us-east-1
This is 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
No additional secrets required! The workflow uses the existing OIDC configuration.
The role is already configured in the workflow file and will automatically authenticate 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 - Role ARN is correct:
arn:aws:iam::058694856476:role/GitHubActionsRole - 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" } } -
Push to branch:
git add web/src/locales/languages/en.json git commit -m "feat: add new dashboard feature text" git push origin feat/new-dashboard-feature -
Workflow automatically:
- Detects
en.jsonchange - Runs translation script
- Translates
newFeatureto all 10 languages - Commits updated
fr.json,es.json, etc. to the same branch
- Detects
-
Build workflows:
- Use the newly updated translation files
- No additional steps needed
Best Practices
- Review Commits: Check auto-generated translation commits for accuracy
- Test in UI: Verify translations display correctly in the application
- Manual Fixes: Edit translations manually if needed - they won't be overwritten
- Context Matters: Some terms may need manual translation for proper context
- Feature Branches: Translations happen on your branch before merging
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 keys are translated (existing translations preserved)
- ✅ Only runs when
en.jsonactually changes - ✅ Works on feature branches (consolidates before merge)
- ✅ 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