aeliot-tm / translation-maintain
The package that helps you keep your translations consistent
Requires
- php: ^7.4|^8.0
- ext-json: *
- google/cloud-translate: ^1.10
- symfony/config: ^3.4|^4.0|5.0|^6.0
- symfony/console: ^3.4|^4.0|5.0|^6.0
- symfony/dependency-injection: ^3.4|^4.0|5.0|^6.0
- symfony/filesystem: ^3.4|^4.0|5.0|^6.0
- symfony/finder: ^3.4|^4.0|5.0|^6.0
- symfony/http-kernel: ^3.4|^4.0|5.0|^6.0
- symfony/translation-contracts: ^1.1|^2.0|^3.0
- symfony/yaml: ^3.4|^4.0|5.0|^6.0
Requires (Dev)
- aeliot-tm/phpunit-codecoverage-baseline: ^2.0
- dg/bypass-finals: ^1.1
- friendsofphp/php-cs-fixer: ^3.8
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ^1.8
- phpstan/phpstan-symfony: ^1.2
- phpunit/phpunit: ^9.5
- symfony/dotenv: ^3.4|^4.0|5.0|^6.0
- symfony/framework-bundle: ^3.4|^4.0|5.0|^6.0
- symfony/translation: ^3.4|^4.0|5.0|^6.0
Suggests
- symfony/translation: Can wrap provided of Translator and log missed translations. Tested with versions: 3.4, 4.4 and 5.3.
README
Package which helps to keep you translations consistent. Compatible with Symfony versions since 3.4.
Installation
Basically, if you use Flex there is enough to execute the command:
composer require --dev aeliot-tm/translation-maintain
See additional information about installation there and description of configuration.
Usage
Testing of translation files
Test your YAML translation files:
php bin/console aeliot_trans_maintain:lint:yaml base
Full information about files transformation see there.
Update YAML files
- Update certain YAML file:
php bin/console aeliot_trans_maintain:yaml:transform <PATH_TO_FILE_TO_BE_UPDATED>
- Update all YAML files in the project:
php bin/console aeliot_trans_maintain:yaml:transform --all
- Update some YAML files of the project which belongs to domain(s) and/or locale(s):
php bin/console aeliot_trans_maintain:yaml:transform --domain=messages --domain=validators --locale=en --locale=de
- Update all YAML files in the specific directory (e.g. not standard or not in the project):
find PATH_TO_DIRECTORY -type f \( -iname \*.yml -o -iname \*.yaml \) | sort | xargs -I {} -t php bin/console aeliot_trans_maintain:yaml:transform $1{}
You can filter them additionally withgrep "some text in the file path"
when you add this before, after or instead ofsort
instruction. And don't forget to separate instructions by the pipe.
Additional information about updating of YAML files see there.
Export missed translations
Example:
php bin/console aeliot_trans_maintain:yaml:export_missed_translations messages en de
Full information about files transformation see there.
Machine Translation via Vendor's API
Full information about machine translation see there.
NOTE: There used standard \Symfony\Component\Yaml\Yaml
class for dumping, so it inserts single-word values without escaping.
Additional description
Article on the Habr (ru): https://habr.com/ru/articles/555954/
You can help to implement more features :) See plans there.