move-elevator/composer-translation-validator

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

1.1.0 2025-07-29 14:58 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, schema validation and more. Supports XLIFF, YAML, JSON and PHP translation files.

✨ Features

🔥 Installation

Packagist Packagist Downloads

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

📊 Usage

Validate your translation files by running the command:

composer validate-translations ./translations

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. 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).