On Laravel 5.5, if you don't use the package in production, disable auto-loading and register it only on local or dev:
Add the following lines in the register method of the AppServiceProvider :
publicfunctionregister()
{
if ($this->app->environment() === 'dev') { // or local or whatever$this->app->register(\Potsky\LaravelLocalizationHelpers\LaravelLocalizationHelpersServiceProvider::class);
}
}
Disable to auto-register provider by adding these lines in the composer.json file:
Now execute php artisan list and you should view the new localization commands:
...
localization
localization:clear Remove lang backup files
localization:find Display all files where the argument is used as a lemma
localization:missing Parse all translations in app directory and build all lang files
...
In Laravel, you can add the facade in the Aliases if you need to manage translations in your code :
You can customize the default generated values for unknown lemmas.
The following command let new values empty:
php artisan localization:missing -l ""
The following command prefixes all lemma values with "Please translate this : "
php artisan localization:missing -l "Please translate this : %LEMMA"
The following command set all lemma values to null to provide fallback translations to all missing values.
php artisan localization:missing -l null
The following command set all lemma values to "Please translate this !"
php artisan localization:missing -l 'Please translate this !'
Silent option for shell integration
#!/bin/bash
php artisan localization:missing -s
if [ $?-eq 0 ];thenecho"Nothing to do dude, GO for release"elseecho"I will not release in production, lang files are not clean"fi
Simulate all operations (do not write anything) with a dry run
php artisan localization:missing -r
Open all must-edit files at the end of the process
php artisan localization:missing -e
You can edit the editor path in your configuration file. By default, editor is Sublime Text on Mac OS X :
new option to specify flat arrays style output (#18)
new option to let the command translate sentences for you with Bing Translator
new translations are now:
marked with the TODO: prefix by default (if you ran two times the missing artisan command without translating lemma next to the first run, your missing translation were lost in the lang file. Now by default, just search for TODO in your lang file!)
translated of course if option t is used
shorten to their minimal value ( trans( 'message.child.this is a text' ) will now generate ['child'] => 'TODO: this is a text', and no more ['child'] => 'TODO: child.this is a text',)
Internally :
totally refactored
unit tests
test coverage
facade to let you use localization helpers in your code (translations, find missing translations, etc...)
v1.3.3
End of life. Version 1.x is no more supported and no longer works. Please use the correct version according to your laravel version.
add support for @lang and @choice in Blade templates (by Jesper Ekstrand)
v1.2.1
add lang_folder_path parameter in configuration file to configure the custom location of your lang files
check lang files in app/lang by default for Laravel 4.x
check lang files in app/resources/lang by default for Laravel 5
v1.2
support for Laravel 5 (4.3)
add ignore_lang_files parameter in configuration file to ignore lang files (useful for validation file for example)
7. Contribute
Fork it
Create your feature branch (git checkout -b my-new-feature)
Commit your changes (git commit -am 'Added some feature')
Push to the branch (git push origin my-new-feature)
Create new Pull Request
Tests are in tests. To run the tests: vendor/bin/phpunit.
Coverage cannot decrease next a merge. To track file coverage, run vendor/bin/phpunit --coverage-html coverage and open coverage/index.html to check uncovered lines of code.
请发表评论