How It Works
The package intelligently:- Compares your source language file with the target language file
- Identifies missing or new keys
- Translates only those missing keys
- Merges them into the existing translation file
Scenario: Adding New Keys
Let’s say you’ve added new features to your application and need to translate only the new keys.Before: Your Source File
Your English filelang/en/messages.php has been updated with new keys:
lang/en/messages.php
Before: Your Target File
Your Spanish filelang/es/messages.php only has the old translations:
lang/es/messages.php
Running the Partial Update
Simply run the translate command - it automatically detects missing keys:After: Your Updated Target File
The Spanish file now contains both old and new translations:lang/es/messages.php
Key Point: The existing translations (
welcome and goodbye) were preserved exactly as they were. Only the missing keys were translated and added.When No Missing Keys Exist
If all keys are already translated, you’ll see:Interactive Mode: Force Re-translation
If you want to re-translate even when no keys are missing (e.g., to improve existing translations), use--interactive:
Validating Partial Updates
After updating, validate that all keys are now present:Best Practices
Regular validation checks
Regular validation checks
Run
translate:validate regularly in your CI/CD pipeline to catch missing translations early:Version control integration
Version control integration
Commit your translation files to version control. When team members add new keys to the source language, others can run:This updates all languages with only the missing keys.
Preserve manual edits
Preserve manual edits
Since partial updates only add missing keys, any manual edits you’ve made to existing translations are preserved. This allows you to:
- Manually refine specific translations
- Keep custom terminology
- Maintain brand voice
Next Steps
Basic Translation
Learn the basics of translating files
Multi-Language
Translate to multiple languages at once