zoutapps / laravel-lang-vendornamespace
Use a translation namespace vor mutliple translation files.
Requires
- illuminate/console: ~5|~6|~7|~8
- illuminate/filesystem: ~5|~6|~7|~8
- illuminate/support: ~5|~6|~7|~8
Requires (Dev)
- mockery/mockery: ^1.1
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~7.0
- sempro/phpunit-pretty-print: ^1.0
README
This package is aimed at package developers that want multiple packages translations under one namespace.
It's currently not easily possible to gather all your packages translations under one namespace which can bloat up the calls to your translations as well as your resources/lang/vendor folder when publishing the files.
For example having packages:
zoutapps/awesome-package
zoutapps/nice-package
you can't register the translations to be able to use them like this:
trans('zoutapps::awesome-package') trans('zoutapps::nice-package')
With this package you now can do this!
Installation
Via Composer
$ composer require zoutapps/laravel-lang-vendornamespace
Usage
In your PackageServiceProvider
instead of using
$this->loadTranslationsFrom(__DIR__ . '/../resources/lang', '<your-vendor-name>')
make a call to
VendorNamespace::loadTranslationsFrom(__DIR__ . '/../resources/lang', '<your-vendor-name>')
in your boot()
method.
Publishing your translations is the same as before:
$this->publishes([ __DIR__ . '/../resources/lang' => resource_path('lang/vendor/<your-vendor-name>'), ], 'lang');
What it does
All paths you register will be added to your translation namespace.
For this to happen, we wait for the application booted callback and:
- we will create a folder for every namespace
- symlink all your provided translation files in the namespace folder
- add the generated folder to the laravel
TranslationLoader
namespaces
Development
While your app environment is set to local
we will always regenerate the links.
When your app is in any other environment, we will check for existence of the lang folder inside our package
and only generate the links if it is not present.
Change log
Please see the changelog for more information on what has changed recently.
Testing
$ composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email oliver.ziegler@zoutapps.de instead of using the issue tracker.
Credits
License
MIT. Please see the license file for more information.