PHP Laravel artisan command that extracting translation contents and updating translation files automatically
slaveofgod/laravel-translator is a Laravel package for php laravel artisan command that extracting translation contents and updating translation files automatically.
It currently has 0 GitHub stars and 9 downloads on Packagist (latest version v1.2).
Install it with composer require slaveofgod/laravel-translator.
Discover more Laravel packages by slaveofgod
or browse all Laravel packages to compare alternatives.
Last updated
The most time-consuming tasks when translating an application is to extract all the template contents to be translated and to keep all the translation files in sync. This package includes a command called translation:update that helps you with these tasks.
$ composer require slaveofgod/laravel-translator dev-master
Update translations from source code.
$ php artisan translation:update {locale} {--force} {--dump-messages}
Arguments:
Name | Description | Default :---------|:----------|:---------- locale | The locale | - path | Directory where to extract the messages | views
Options:
Name | Description | Default :---------|:----------|:---------- force | Should the update be done | false dump-messages | Should the messages be dumped in the console | false no-backup | Should backup not be done | false clean | Should clean not found messages. But we will ignore next files: 'validation', 'auth', 'passwords', 'pagination' | false prefix | Override the default prefix. | __,@lang,trans_choice,@choice,__ab,@lang_ab,trans_choice_ab,@choice_ab
Update translations with untracked messages.
If you want to be able to tracked untracked messages please use __ab and trans_choice_ab.
What is untracked message: {{ __($message) }} or {{ trans_choice($message, 5, ['value' => 5]) }}.
When you use __ab, trans_choice_ab, @lang_ab or @choice_ab function they will work the same way as __, trans_choice``@lang or @choice plus loging all messages to the special log file.
$ php artisan translation:untracked {locale} {--force} {--dump-messages}
Arguments:
Name | Description | Default :---------|:----------|:---------- locale | The locale | -
Options:
Name | Description | Default :---------|:----------|:---------- force | Should the update be done | false dump-messages | Should the messages be dumped in the console | false no-backup | Should backup not be done | false
Difference between translation files and source code messages.
php artisan translation:diff en
Arguments:
Name | Description | Default :---------|:----------|:---------- locale | The locale | - path | Directory where to extract the messages | views
Options:
Name | Description | Default :---------|:----------|:---------- prefix | Override the default prefix. | __,@lang,trans_choice,@choice,__ab,@lang_ab,trans_choice_ab,@choice_ab
if for any reason artisan can't find commands, you can register the provider manually on your config/app.php file:
return [
...
'providers' => [
...
AB\Laravel\Translator\ServiceProvider::class,
...
]
]