https://github.com/pfcode/symfony-i18n-comparator
Utility for comparison of duplicated translation files in Symfony projects.
https://github.com/pfcode/symfony-i18n-comparator
Last synced: 4 months ago
JSON representation
Utility for comparison of duplicated translation files in Symfony projects.
- Host: GitHub
- URL: https://github.com/pfcode/symfony-i18n-comparator
- Owner: pfcode
- License: mit
- Created: 2021-05-31T18:45:47.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-31T18:57:26.000Z (over 4 years ago)
- Last Synced: 2025-07-27T01:39:52.334Z (4 months ago)
- Language: PHP
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# I18nComparatorBundle
Utility for making a comparison of duplicated translation files in Symfony projects.
### Use case
The case this util resolves is very specific - it's intended to help find differences between
translation files belonging to the same domain and language, but saved in different formats
(messages.en.xlf and messages.en.yml, for example).
Note: Such differences should not occur under usual circumstances when using symfony/translation component.
Please see the _Example_ section below and check if this bundle actually solves your problem.
### Installation
You can add this bundle into your Symfony project using Composer:
```bash
composer require pfcode/symfony-i18n-comparator
```
This bundle requires at least Symfony 4.4 or 5.0 and PHP 7.1 or later and it's not intended to be used
on production environments.
### Example
Let's say you have two translation files in your project, that belong to the same domain and are in the same language:
_translations/messages.en.xlf_:
```xml
nav.home
Dashboard
nav.login
Sign In
nav.logout
Logout
```
_translations/messages.en.yml_:
```yaml
nav:
home: 'Home'
login: 'Sign In'
logout: 'Sign Out'
search: 'Search something...'
```
These translation files obviously have some differences. One of them has nav.search key missing and other messages have
different values. Comparing those files in a text editor would be painful.
To compare them at the logical level (translation keys, that is), you can use a command provided by this bundle:
```
bash-4.4# bin/console i18n-comparator:find-conflicts --translations-dir=translations
+---------------------+-- messages.en ------+-----------------+
| Key | messages.en.yml | messages.en.xlf |
+---------------------+---------------------+-----------------+
| messages.nav.home | Home | Dashboard |
| messages.nav.logout | Sign Out | Logout |
| messages.nav.search | Search something... | |
+---------------------+---------------------+-----------------+
```
With this command, searching for differences across various translation formats should be a lot easier.
### Supported translation formats
This bundle registers a ComparatorFactory service and passes references to all known translation loaders
(all services tagged by `translation.loader`) to it. So it supports all formats
that your Symfony installation already does.
### License
This project is distributed under the MIT license.