This document explains how to use the automated translation system powered by Potomatic for WP Fusion.
-
Install dependencies:
npm install
-
Set up your OpenAI API key:
cp env-example.txt .env # Edit .env and add your OpenAI API key -
Generate translations:
npm run release
npm run translate:pot- Generate .pot file onlynpm run translate- Generate translations from existing .pot filenpm run translate:mo- Convert .po files to .mo filesnpm run version:update- Update version numbers in files
npm run build- Standard build (includes .pot generation)npm run release- Full release with translations
gulp build- Build without translationsgulp release- Build with translationsgulp generatePotFile- Generate .pot filegulp generateTranslations- Generate translations onlygulp createMoFiles- Generate .mo files from .po files
Copy env-example.txt to .env and configure:
# Required
API_KEY=your_openai_api_key_here
# Optional (defaults shown)
MODEL=gpt-4o
TEMPERATURE=0.3
MAX_COST=50
BATCH_SIZE=15
MAX_RETRIES=3
VERBOSE_LEVEL=1Currently configured to translate to:
- Spanish (es_ES)
- French (fr_FR)
- German (de_DE)
- Italian (it_IT)
- Portuguese Brazil (pt_BR)
- Dutch (nl_NL)
- Russian (ru_RU)
- Japanese (ja)
- Chinese Simplified (zh_CN)
- Korean (ko_KR)
To modify languages, edit the targetLanguages array in gulpfile.js.
The system uses specialized dictionaries for consistent translations:
config/dictionaries/common.json- Core WP Fusion terminologyconfig/dictionaries/crm-terms.json- CRM-specific termsconfig/dictionaries/wordpress-terms.json- WordPress-specific terms
The translation prompt is in config/prompt.md and includes:
- Context about WP Fusion and its purpose
- Guidelines for WordPress terminology
- Instructions for handling technical terms
- Style and tone guidelines
Custom headers are defined in config/po-header.json and include:
- Project information
- Contact details
- Generator information
- Poedit configuration
- POT Generation: WordPress CLI generates the .pot file with all translatable strings
- Translation: Potomatic uses OpenAI to translate strings using context-aware prompts
- Dictionary Lookup: Consistent terminology is ensured using specialized dictionaries
- PO File Creation: Translated .po files are generated with proper headers
- MO File Generation: Binary .mo files are created for WordPress to use
wp-fusion/
├── config/
│ ├── dictionaries/
│ │ ├── common.json
│ │ ├── crm-terms.json
│ │ └── wordpress-terms.json
│ ├── po-header.json
│ └── prompt.md
├── languages/
│ ├── wp-fusion.pot
│ ├── wp-fusion-es_ES.po
│ ├── wp-fusion-es_ES.mo
│ └── ... (other language files)
├── gulpfile.js
├── package.json
└── .env (you create this)
Translation costs are controlled through:
MAX_COSTenvironment variable (default: $50)BATCH_SIZEfor API efficiency (default: 15 strings per request)MAX_RETRIESfor failed requests (default: 3)
- Missing .env file: Copy
env-example.txtto.envand configure - No OpenAI API key: Get one from https://platform.openai.com/api-keys
- Translation failures: Check your API key, quota, and network connection
- Missing .mo files: Run
npm run translate:moor check ifmsgfmtis installed
Set VERBOSE_LEVEL=3 in your .env file for detailed debugging output.
If automatic translation fails, you can:
- Generate the .pot file:
npm run translate:pot - Use traditional translation tools like Poedit
- Place .po files in the
languages/directory - Generate .mo files:
npm run translate:mo
The translation system is integrated into the standard build process:
- Development: Use
npm run build(no translations) - Release: Use
npm run release(includes translations)
This ensures translations are always up-to-date when releasing new versions.
When adding new translatable strings:
- Use proper WordPress i18n functions (
__(),_e(), etc.) - Include translator comments for context:
// translators: %s is the CRM name sprintf( __( 'Connected to %s', 'wp-fusion' ), $crm_name )
- Add new terminology to the appropriate dictionary files
- Test translations with
npm run translate
For translation-related issues:
- Check the troubleshooting section above
- Review Potomatic documentation: https://github.com/GravityKit/Potomatic
- Open an issue with WP Fusion support