databaselaravellaravel-localization

How to use db instead of Laravel localization config file


I'm using mcamara/laravel-localization. I need to get languages from db instead of laravellocalization config file. Any ideas how to do that. I would be so grateful.


Solution

  • Your best option is to use the laravel translation loader:

    Install Laravel translation loader through Composer:

    composer require spatie/laravel-translation-loader
    

    Then publish Laravel translation loader migration file:

     php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="migrations"
    

    Finally, run the migrations; it will create a new table called language_lines in the database:

    php artisan migrate
    

    UPDATE: for laravel 6+ see the Issue @ github

    source: Laravel news