move-elevator/composer-translation-validator

A Composer plugin that validates translations files in your project regarding mismatches between language source and target files.

0.4.0 2025-07-05 14:07 UTC

README

Composer Translation Validator

Coverage CGL Tests Supported PHP Versions

A Composer plugin that validates translation files in your project. Provides a command validate-translations to check for translations mismatches, duplicates and schema validation.

✨ Features

  • Autodetect coherent language files
  • Supports various translation formats
  • Provides multiple validators

🔥 Installation

Packagist Packagist Downloads

composer require --dev move-elevator/composer-translation-validator

📊 Usage

composer validate-translations [<path>]

console.png

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.

composer validate-translations [<path>] [-dr|--dry-run] [-f|--format cli|json] [-e|--exclude PATTERN] [-s|--skip VALIDATOR] [-o|--only VALIDATOR] [-v|--verbose]

📝 Documentation

Supported Formats

The plugin supports the following translation file formats (and targets the following frameworks):

Format Description Framework Example files
XLIFF Supports source/target translations in xliff language files. TYPO3 CMS locallang.xlf, de.locallang.xlf
Yaml Supports yaml language files. Symfony Framework messages.en.yaml, messages.de.yaml

Validators

The following validators are available:

Validator Function Supports Throws
MismatchValidator This validator checks for keys that are present in some files but not in others. It helps to identify mismatches in translation keys across different translation files. XLIFF, Yaml ERROR
DuplicateKeysValidator This validator checks for duplicate keys in translation files. XLIFF ERROR
DuplicateValuesValidator This validator checks for duplicate values in translation files. XLIFF, Yaml WARNING
SchemaValidator Validates the XML schema of translation files against the XLIFF standard. See available schemas. XLIFF ERROR

🧑‍💻 Contributing

Please have a look at CONTRIBUTING.md.

⭐ License

This project is licensed under GNU General Public License 3.0 (or later).