bezhanSalleh / filament-language-switch

A versatile and user-friendly plugin designed for Filament Panels.
MIT License
226 stars 44 forks source link

display languages from database data #28

Closed valpuia closed 1 year ago

valpuia commented 1 year ago

Hi, is there a way to display the languages from database..

Normally we have App\Models\Language to store all of our supported languages, and we need to comment/uncomment the languages from config based on the languages we supported.. If we make one languages active/inactive from database then we need to change config and push the changes again and again..

So if there is an option to load languages (locale, name, flag) from database base on query() and it will be very convenient for all the end user as well

Sorry for bad english.. thanks in advance

deveti commented 1 year ago

What I did is, I created a settings page (spatie-settings), where I have Select with hardcoded values of "available" languages. Then in AppServiceProvider boot method I added:

config([
    'filament-spatie-laravel-translatable-plugin.default_locales' => app(GeneralSettings::class)->site_languages
]);

You could make a new resource and use that to read languages from database for example.