F
Filamentβ€’8mo ago
slimdeluxe

How to set the default content language when using the Translatable plugin?

I added the Spatie Translatable plugin and everything works, but I am looking for a way to set the default language that is used for the content. E.g. when I use the switcher to change the language to Slovenian and then proceed to open the Edit page for a record, the editor should also open in the same language. Also when I go back to the list, should be the same. Basically I am looking how to persist the language choice so that when you are working with a translation, you don't have to keep switching the language for every page load. I tried setting the Laravel locale config in app.php but this is not used as a default choice for the content language. The plugin is initialized like so:
$panel->plugin(SpatieLaravelTranslatablePlugin::make()
->defaultLocales(['en', 'sl']));
$panel->plugin(SpatieLaravelTranslatablePlugin::make()
->defaultLocales(['en', 'sl']));
I don't see any specific option on the plugin object. It's weird however that the method is called "defaultLocales"... maybe it should be "availableLocales" to make it more clear πŸ™‚
1 Reply
slimdeluxe
slimdeluxeβ€’8mo ago
Ok, found a workaround... the first language you pass to the defaultLocales method is the one that is initialized... so I could implement a session-wide language switcher and then pass that language as the first option, then the rest of the available languages
Want results from more Discord servers?
Add your server