Translations
Translations
Language files in the package can have two different formats.
- the classic PHP files
- JSON files.
Bootraiser works with the PHP files and also with the JSON files automatically and requires no extra configuration.
To load the package translation files use load.
<?php
namespace YourCompany\YourPackage\Providers;
use Filefabrik\Bootraiser\Raiser;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
Raiser::forProvider($this)->loadTranslations();
}
}publishable
To publish the package translation files, use publish
<?php
namespace YourCompany\YourPackage\Providers;
use Filefabrik\Bootraiser\Raiser;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
Raiser::forProvider($this)->publishTranslations();
}
}If load and publish are to be used, use Translations
<?php
namespace YourCompany\YourPackage\Providers;
use Filefabrik\Bootraiser\Raiser;
use Illuminate\Support\ServiceProvider;
class YourPackageServiceProvider extends ServiceProvider
{
public function boot(): void
{
Raiser::forProvider($this)->Translations();
}
}publish command translations
The package translations are offered in bootraiser, as intended in laravel, via vendor:publish
php artisan vendor:publish
specifically with publish-tag for the package
php artisan vendor:publish --tag=your-package-translationsBootraiser Options
Possible instructions
with method
Raiser::forProvider($this)->Translations();Raiser::forProvider($this)->loadTranslations();Raiser::forProvider($this)->publishTranslations();
with array
['Translations']['loadTranslations']['publishTranslations']
References
https://laravel.com/docs/11.x/packages#language-files
https://laravel.com/docs/11.x/localization#defining-translation-strings
laravel translations
https://laravel.com/docs/11.x/localization#overriding-package-language-files
good explanation
https://laraveldaily.com/lesson/multi-language-laravel/php-json-trans-underscores
Last updated on