### Package Installation Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md Command to install the spatie/laravel-translation-loader package using Composer. ```bash composer require spatie/laravel-translation-loader ``` -------------------------------- ### Publishing Migrations and Configuration Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md Commands to publish the package's migrations and configuration files, followed by running the database migrations. ```bash php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="translation-loader-migrations" php artisan migrate ``` ```bash php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="translation-loader-config" ``` -------------------------------- ### Run Tests Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md Command to execute the test suite for the package using Composer. ```bash composer test ``` -------------------------------- ### Service Provider Replacement Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md Shows how to replace Laravel's default translation service provider with the package's provider in `config/app.php` or `bootstrap/app.php`. ```php Illuminate\Translation\TranslationServiceProvider::class, ``` ```php Spatie\TranslationLoader\TranslationServiceProvider::class, ``` -------------------------------- ### Published Configuration File Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md The default configuration file content for the package, showing how to specify translation loaders and the model to use. ```php return [ /* * Language lines will be fetched by these loaders. You can put any class here that implements * the Spatie\TranslationLoader\TranslationLoaders\TranslationLoader-interface. */ 'translation_loaders' => [ Spatie\TranslationLoader\TranslationLoaders\Db::class, ], /* * This is the model used by the Db Translation loader. You can put any model here * that extends Spatie\TranslationLoader\LanguageLine. */ 'model' => Spatie\TranslationLoader\LanguageLine::class, /* * This is the translation manager that overrides the default Laravel `translation.loader` */ 'translation_manager' => Spatie\TranslationLoader\TranslationLoaderManager::class, ]; ``` -------------------------------- ### Basic Translation Usage Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md Demonstrates how to use the `__` helper function with the package to retrieve translated strings, including dynamic parameters. ```php __('messages.welcome', ['name' => 'dayle']); ``` -------------------------------- ### Create Translation Entry Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md Demonstrates how to create a new translation entry in the database using the LanguageLine model. It specifies the group, key, and the translated text for different locales. ```php use Spatie\TranslationLoader\LanguageLine; LanguageLine::create([ 'group' => 'validation', 'key' => 'required', 'text' => ['en' => 'This is a required field', 'nl' => 'Dit is een verplicht veld'], ]); ``` -------------------------------- ### Retrieve Translation Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md Shows how to retrieve translations using Laravel's default __ function after setting the application locale. It illustrates fetching translations for 'en' and 'nl' locales. ```php __('validation.required'); // returns 'This is a required field' app()->setLocale('nl'); __('validation.required'); // returns 'Dit is een verplicht veld' ``` -------------------------------- ### TranslationLoader Interface Source: https://github.com/spatie/laravel-translation-loader/blob/main/README.md Defines the TranslationLoader interface, which custom translation providers must implement. It includes the loadTranslations method for loading translations based on locale and group. ```php namespace Spatie\TranslationLoader\TranslationLoaders; interface TranslationLoader { /* * Returns all translations for the given locale and group. */ public function loadTranslations(string $locale, string $group): array; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.