PHP code example of aon4o / laravel-translation-loader

1. Go to this page and download the library: Download aon4o/laravel-translation-loader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aon4o / laravel-translation-loader example snippets


__('messages.welcome', ['name' => 'dayle']);
// or
__('clients::messages.welcome', ['name' => 'dayle']);

Illuminate\Translation\TranslationServiceProvider::class,

Spatie\TranslationLoader\TranslationServiceProvider::class,

return [

    /*
     * The name of the table in which the language lines are stored.
     */
    'table_name' => 'language_lines',

    /*
     * 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 which overrides the default Laravel `translation.loader`
     */
    'translation_manager' => Spatie\TranslationLoader\TranslationLoaderManager::class,

];

use Spatie\TranslationLoader\LanguageLine;

LanguageLine::create([
    'namespace' => '*',
    'group' => 'validation',
    'key' => '

__('validation.ale('nl');

__('validation.

namespace Spatie\TranslationLoader\TranslationLoaders;

interface TranslationLoader
{
    /*
     * Returns all translations for the given locale and group.
     */
    public function loadTranslations(string $locale, string $group, string|null $namespace = null): array;
}
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"