move-elevator / composer-translation-validator
A Composer plugin that validates translations files in your project regarding mismatches between language source and target files.
Installs: 815
Dependents: 4
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 4
Type:composer-plugin
Requires
- php: ^8.1
- composer-plugin-api: ^1.0 || ^2.0
- ext-libxml: *
- ext-mbstring: *
- ext-simplexml: *
- justinrainbow/json-schema: ^5.3 || ^6.4
- psr/log: ^1.0 || ^2.0 || ^3.0
- symfony/config: ^5.0 || ^6.0 || ^7.0
- symfony/console: ^5.0 || ^6.0 || ^7.0
- symfony/filesystem: ^5.0 || ^6.0 || ^7.0
- symfony/translation: ^5.0 || ^6.0 || ^7.0
- symfony/yaml: ^5.0 || ^6.0 || ^7.0
Requires (Dev)
- armin/editorconfig-cli: ^1.0 || ^2.0
- composer/composer: ^2.0
- eliashaeussler/php-cs-fixer-config: 2.3.0
- eliashaeussler/rector-config: ^3.0
- ergebnis/composer-normalize: ^2.44
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^10.2 || ^11.0 || ^12.0
- roave/security-advisories: dev-latest
Suggests
- ext-intl: Required for validating translations regarding unicode normalization issues.
- dev-main
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.1
- 0.1.0
- dev-key-depth-validator
- dev-key-count-validator
- dev-value-objects-api
- dev-refactor-domain-architecture
- dev-api-first
- dev-mismatch-validator-error
- dev-minify-test-sute
- dev-fix-key-naming-convention-validator
- dev-doc-version-hint
- dev-improve/refactor-validate-command-orchestration
- dev-format-github
- dev-improve-documentation
- dev-fix-prefix-file-detector
- dev-fix-xliff-schema-output
- dev-fix-key-naming-enum
- dev-update/modernize-constants-to-enums
- dev-update/php81-modernization-features
- dev-key-naming-validator
- dev-reusable-github-actions
- dev-html-tag-validator
- dev-phpstan-8
- dev-widen-dependencies
- dev-renovate
- dev-file-headers
- dev-xliff-target-language-fix
- dev-recursive
- dev-readme-adjustments
- dev-phpstan-7
- dev-encoding-validator
- dev-support-php
- dev-json-support
- dev-placeholder-validator
- dev-empty-value-validator
- dev-code-style
- dev-code-improvement
- dev-symfony-5-test
- dev-xliff-schema-1.0
- dev-warning-strict
- dev-config
- dev-parser-cache
- dev-result-message
- dev-statistics
- dev-output-style
- dev-validation-run
- dev-symfony-read-file
- dev-skip-only
- dev-duplicate-values
- dev-result-renderer
- dev-result-type
- dev-rename-duplicates-validator
- dev-format-json
- dev-unit-testing
This package is auto-updated.
Last update: 2025-07-30 06:52:41 UTC
README
Composer Translation Validator
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.
✨ Features
- Autodetect coherent language files
- Supports various translation file formats
- Provides multiple validators
- Configurable via separate configuration files
🔥 Installation
composer require --dev move-elevator/composer-translation-validator
📊 Usage
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.
📝 Documentation
Supported File Formats
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.
Translation Validators
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.
🧑💻 Contributing
Please have a look at CONTRIBUTING.md
.
⭐ License
This project is licensed under GNU General Public License 3.0 (or later).