This project demonstrates automated translation processing using GitHub Actions and the PTC CLI tool.
Check .github/workflows/translations.yml for the workflow configuration.
simple-json-translations/
├── .github/workflows/
│ └── translations.yml # GitHub Actions workflow for automated translations
├── locales/
│ ├── admins-en.json # Admin panel translations (processed)
│ └── en.json # Main application translations (processed)
├── ignore-this-en.json # Ignored file (NOT processed for translation)
├── root.en.json # Root-level translations (processed)
└── README.md # This file
The following English source files are automatically processed for translation:
-
locales/admins-en.json- Contains admin panel translations{ "admins": { "title": "Admins", "description": "Admins page" } } -
locales/en.json- Main application translations{ "hello": "Hello", "world": "World" } -
root.en.json- Root-level translations{ "hi": "Five!" }
ignore-this-en.json- This file is intentionally excluded from translation processing, even though it follows the*-en.jsonpattern. It contains content that should not be translated.
The project uses GitHub Actions to automatically process translations using the PTC CLI tool.
-
Trigger: The workflow runs automatically when:
- Changes are pushed to
mainbranches - Files matching
locales/*en.jsonorroot.en.jsonare modified - Manual trigger via GitHub Actions UI
- Changes are pushed to
-
Translation Process:
- Downloads and sets up the PTC CLI tool
- Scans for English source files using patterns:
locales/*{{lang}}.json,root.{{lang}}.json - Uploads source files to PTC (Private Translation Cloud) API
- Processes translations for multiple target languages (Defined in PTC Dashboard)
- Downloads completed translations
-
Output: Creates a Pull Request with:
- Translated files for each target language (e.g.,
locales/de.json,locales/fr.json,root.de.json) - Automatic commit message: "🌐 Update translations via PTC CLI"
- Detailed PR description with trigger information
- Translated files for each target language (e.g.,
The workflow utilizes the PTC CLI tool, which provides:
- Flexible file processing using glob patterns
- API integration with Private Translation Cloud
- Step-based workflow: Upload → Process → Monitor → Download
- Progress monitoring with status indicators
- Error handling suitable for CI/CD environments
- Multiple output formats support
- Pattern-based file discovery
- Bearer token authentication via environment variables (See Environment Secrets)
- Verbose logging for debugging
- Automatic language code substitution (
{{lang}}placeholder)
PTC_API_TOKEN- Required secret for PTC API authentication
The GitHub Actions workflow requires:
contents: write- To create commits with translated filespull-requests: write- To create pull requests
You need to enable "Allow GitHub Actions to create and approve pull requests" - Github Actions Permissions. Otherwise, the workflow will fail with the following error:
Error: You are not authorized to create a pull request.
To test the translation workflow locally:
-
Set up your PTC API token:
export PTC_API_TOKEN=your-secret-token -
Download and run PTC CLI:
curl -fsSL https://raw.githubusercontent.com/OnTheGoSystems/ptc-cli/refs/heads/main/ptc-cli.sh -o ptc-cli.sh chmod +x ptc-cli.sh ./ptc-cli.sh --source-locale en --patterns "locales/*{{lang}}.json,root.{{lang}}.json" --api-token="$PTC_API_TOKEN" --verbose
- The
ignore-this-en.jsonfile demonstrates how certain files can be excluded from translation by not matching the configured patterns - All translated files are automatically committed and submitted as pull requests
- Translation status is monitored with real-time progress indicators