bottelet / translation-checker
A translation checker package for Laravel, find, add, and translate missing strings
Installs: 2 438
Dependents: 0
Suggesters: 0
Security: 0
Stars: 96
Watchers: 3
Forks: 6
Open Issues: 4
Requires
- php: ^8.1
- deeplcom/deepl-php: ^1.9
- google/cloud-translate: ^1.17
- nikic/php-parser: ^v5.2
- openai-php/client: ^0.10.1
- stichoza/google-translate-php: ^5.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- orchestra/testbench: ^7.0|^8.0|^9.0
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.4|^10.1|^11.0
README
Translation Checker is tool designed to help you find translations you forgot to add to your language files, check, and maintain translations in your project. It provides a set of commands to help with language files, ensuring consistency and completeness across your translations.
It works with Laravel and supports various frontend frameworks like Vue.js, React, and Svelte.
How it works
- Scan Source Files: The system looks through your code for strings that need translation.
- Check Language Files: It then checks if these strings exist in your language files.
- Add missing translation keys: It adds the missing key with empty values if there is no translation service used.
Example:
lang.json
{ "test.value": "Value" }
lang.php
return [ 'test.value' => 'Value', ];
TestClass.php
class TestClass { public function getValue() { return __('translate this string'); } }
php artisan translations:check en
lang.json
{ "test.value": "Value", "translate this string": null }
lang.php
return [ 'test.value' => 'Value', 'translate this string' => null, ];
The reason we default to null when no translation service are used is because it defaults to the key used in the function call.
Quick Start
Install the package via composer:
composer require bottelet/translation-checker --dev
Usage
Translation Checker provides several commands to manage your translations. The most versatile is the check
command:
php artisan translations:check en
For detailed information on all available commands and their usage, refer to the documentation.
Testing
Run the tests with:
./vendor/bin/phpunit
Documentation
For full documentation, visit our GitHub documentation page.
If you encounter any issues or have suggestions, please create an issue on GitHub.
License
The MIT License (MIT). Please see License File for more information.