A Composer plugin that validates translation files in your project.
Provides a command validate-translations
to check for translations mismatches, duplicates, schema validation and more.
Supports XLIFF, YAML, JSON and PHP translation files.
- Autodetect coherent language files
- Supports various translation file formats
- Provides multiple validators
- Configurable via separate configuration files
composer require --dev move-elevator/composer-translation-validator
Validate your translation files by running the command:
composer validate-translations ./translations
The command validate-translations
can be used to validate translation files in your project. It will automatically detect the translation files based on the supported formats and run the configured validators. See the console command documentation for more details.
Translations will be detected and grouped by the following file formats (regarding the associated frameworks):
Format | Frameworks | Example files |
---|---|---|
XLIFF | TYPO3 CMS | locallang.xlf , de.locallang.xlf |
YAML | Symfony | messages.en.yaml , messages.de.yaml |
JSON | Laravel, Symfony | messages.en.json , messages.de.json |
PHP | Laravel, Symfony | en/messages.php , messages.en.php |
See detailed file format and file detection documentation with examples.
The following translation validators are available (and enabled by default):
Validator | Description |
---|---|
DuplicateKeysValidator | Catches duplicate keys within files |
DuplicateValuesValidator | Finds identical translation values |
EmptyValuesValidator | Detects empty or whitespace-only values |
EncodingValidator | Validates UTF-8 encoding and Unicode issues |
HtmlTagValidator | Ensures HTML tag consistency across languages |
KeyCountValidator | Warns when files exceed a configurable key count threshold |
KeyDepthValidator | Warns when translation keys have excessive nesting depth |
KeyNamingConventionValidator | Enforces key naming patterns (requires config) |
MismatchValidator | Finds missing translations between files |
PlaceholderConsistencyValidator | Validates placeholder patterns |
XliffSchemaValidator | Validates XLIFF against XML schemas |
View detailed validator documentation with examples.
Please have a look at CONTRIBUTING.md
.
This project is licensed under GNU General Public License 3.0 (or later).