coding-socks / lost-in-translation
This package helps to find missing translation strings in your Laravel blade files
Installs: 1 438
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 1
Forks: 1
Open Issues: 2
Requires
- php: ^8.0
- illuminate/console: ^9.0 || ^10.0 || ^11.0
- illuminate/filesystem: ^9.0 || ^10.0 || ^11.0
- illuminate/support: ^9.0 || ^10.0 || ^11.0
- illuminate/translation: ^9.0 || ^10.0 || ^11.0
- illuminate/view: ^9.0 || ^10.0 || ^11.0
- nikic/php-parser: ^4.18 || ^5.0
Requires (Dev)
- orchestra/testbench: ^7.3 || ^8.0 || ^9.0
- phpunit/phpunit: ^9.5 || ^10.5
This package is auto-updated.
Last update: 2024-10-29 09:53:29 UTC
README
This package helps to find missing translation strings in your Laravel blade files.
Installation
You can easily install this package using Composer, by running the following command:
composer require coding-socks/lost-in-translation --dev
Usage
You can list all missing translation for a specific location using the command below.
php artisan lost-in-translation:find {locale}
Example:
php artisan lost-in-translation:find nl
It is sometimes recommended to increase the verbosity using -v
flag. In verbose mode the command will print warnings and errors to the standard output.
Publish
Publish the configuration file only:
php artisan vendor:publish --tag=lost-in-translation-config
Publish the Command class only:
php artisan vendor:publish --tag=lost-in-translation-commands
Defaults
The command considers app.locale
as your applications default locale.
The command scans your lang
directory for comparison with the default and target locale.
The command scans your app
, and resources/views
directory for translation retrieval.
The command detects the following in your blade and application files:
@lang('key')
Blade directives are compiled toapp('translator')->get('key')
__('key')
any call to the__
functiontrans('key')
any call to thetrans
functiontrans_choice('key', x)
any call to thetrans_choice
functionapp('translator')->get('key')
any directget
method call on thetranslator
App::make('translator')->get('key')
any directget
method call on thetranslator
Lang::get('key')
anyget
static call on theLang
facade<<<'blade'
inline components in nowdoc withblade
label are compiled and their content is scanned.
Help
Description:
Find missing translation strings in your Laravel blade files
Usage:
lost-in-translation:find [options] [--] <locale>
Arguments:
locale The locale to be checked
Options:
--sorted Sort the values before printing
--no-progress Do not show the progress bar
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi|--no-ansi Force (or disable --no-ansi) ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Implementation
This implementation reads all your blade files, compiles them to PHP (illuminate/view), parses them as PHP (nikic/php-parser), and then finds the relevant nodes in the AST.
This, in my opinion, is a cleaner and less error-prone than using regular expressions.