PHP code example of bezhansalleh / filament-language-switch
1. Go to this page and download the library: Download bezhansalleh/filament-language-switch 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/ */
bezhansalleh / filament-language-switch example snippets
...
use BezhanSalleh\FilamentLanguageSwitch\LanguageSwitch;
class AppServiceProvider extends ServiceProvider
{
...
public function boot()
{
...
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch
->locales(['ar','en','fr']); // also accepts a closure
});
...
}
}
// AppServiceProvider.php
...
use BezhanSalleh\FilamentLanguageSwitch\Enums\Placement;
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch
...
->outsidePanelPlacement(Placement::BottomRight)
// Sets the language switch to appear at the bottom right outside of panels
...;
});
...
// AppServiceProvider.php
...
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch
...
->displayLocale('fr') // Sets French as the language for label localization
...;
});
...