This repository demonstrates how to use PTC CLI to automate the translation process for WordPress plugins and themes.
The project shows a complete workflow for translation processing:
- 📤 Upload
.potfiles to PTC (Private Translation Cloud) - 🔄 Automatic translation generation
- 📥 Download ready
.poand.mofiles - 🤖 Automation via GitHub Actions
.
├── .github/workflows/ptc.yml # GitHub Actions workflow
├── .ptc/config.yml # PTC CLI configuration
├── languages/ # Translations folder
│ ├── examplewp.pot # Source translation file
│ ├── examplewp-*.po # Translation files
│ └── examplewp-*.mo # Compiled translations
└── README.md # This documentation
source_locale: en
files:
- file: languages/examplewp.pot
output: languages/examplewp-{{lang}}.po
additional_translation_files:
- type: mo
path: languages/examplewp-{{lang}}.mo
- type: wp
path: languages/examplewp-{{lang}}.json
- type: php
path: languages/examplewp-{{lang}}.l10n.phpParameter descriptions:
source_locale: en- source language (English)file- path to source.potfileoutput- template for output files ({{lang}} is replaced with language code)additional_translation_files- additional file formats:mo- compiled files for WordPresswp- JSON files for JavaScript translationsphp- PHP files for modern WordPress translations
The workflow automatically triggers on:
- Push to
mainbranch with changes inconfig/locales/**/*.yml - Manual trigger through GitHub UI
- Get your API token from PTC Dashboard
- Add token to repository secrets:
- Go to
Settings→Secrets and variables→Actions - Create new secret
PTC_API_TOKEN - Paste your token
- Go to
# Clone the repository
git clone <your-repo-url>
cd gh-simple-wordpress-translations-with-ptc-cli
# Download 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
# Run translation processing
./ptc-cli.sh --config-file .ptc/config.yml --api-token your-secret-token --verbose- Ensure
PTC_API_TOKENis configured in secrets - Enable Actions permissions:
Settings→Actions→GeneralWorkflow permissions→ ✅ "Allow GitHub Actions to create and approve pull requests"
- Run the workflow:
- Go to
Actionstab - Select "Process Translation Files"
- Click "Run workflow"
- Go to
PTC CLI performs the following steps:
- 📤 Upload -
examplewp.potfile is uploaded to PTC - ⚙️ Processing - automatic translation is triggered
- 👀 Monitoring - translation status is tracked:
🔵 QQ 1/30 → Queued 🔵 PP 15/30 → Processing 🟢 CC 28/30 → Completed - 📥 Download - ready translations are saved to
languages/
files:
- file: path/to/your.pot
output: path/to/translations/your-{{lang}}.po
additional_translation_files:
- type: mo
path: path/to/translations/your-{{lang}}.mo# Increase timeout
./ptc-cli.sh --config-file .ptc/config.yml --monitor-max-attempts 60
# Change check interval
./ptc-cli.sh --config-file .ptc/config.yml --monitor-interval 10HTTP 401 Unauthorized
[ERROR] Failed to upload file: examplewp.pot (HTTP 401)
✅ Solution: Check your API token is correct
Files Not Found
[ERROR] No files found for pattern: examplewp.pot
✅ Solution: Ensure the file exists and path is correct
Translation Timeout
[WARNING] Timed out files: 1
✅ Solution: Increase --monitor-max-attempts or check status manually
For detailed diagnostics use:
./ptc-cli.sh --config-file .ptc/config.yml --verbose --dry-runPTC CLI provides colored logs:
- 🔵 INFO - general information
- 🟢 SUCCESS - successful operations
- 🟡 WARNING - warnings
- 🔴 ERROR - errors
- 🔵 DEBUG - detailed information (only with --verbose)
This setup is perfect for:
- WordPress Plugin Development - automate translations for international distribution
- Theme Development - provide multilingual support out of the box
- CI/CD Integration - automatic translation updates on code changes
- Team Collaboration - consistent translation workflow across team members
- Update your
.potfile with new strings - Run the GitHub Action manually
- Review the generated Pull Request
- Merge translations
- Commit changes to translation source files
- Push to main branch
- GitHub Actions automatically processes translations
- Pull Request is created with updates
- ✅ Store API tokens in GitHub Secrets, never in code
- ✅ Use environment variables for local development
- ✅ Review translation PRs before merging
💡 Tip: This repository serves as a template. Fork it and adapt it to your needs!