zakariatlilani / translation-manager
Manage your application's translation in Filament.
Package info
github.com/ZakariaTlilani/translation-manager
pkg:composer/zakariatlilani/translation-manager
Requires
- php: ^8.2
- filament/filament: ^5.0
- filament/notifications: ^5.0
- spatie/laravel-package-tools: ^1.92
- spatie/laravel-translation-loader: ^2.8
- stijnvanouplines/blade-country-flags: ^1.0.6
Requires (Dev)
- tightenco/duster: ^2.0
README
This package uses spatie/laravel-translation-loader, Make sure your migration is done correctly.
This package uses phpfilament v5, make sure you have php 8.2 or greater.
Installation
You can install the package via composer:
composer require zakariatlilani/translation-manager
Plugin Configuration
use ZakariaTlilani\TranslationManager\TranslationManagerPlugin; TranslationManagerPlugin::make() ->availableLocales([ ['code' => 'en', 'name' => 'English', 'flag' => 'gb'], ['code' => 'fr', 'name' => 'Français', 'flag' => 'fr'], ]) ->languageSwitcher(true) ->languageSwitcherRenderHook('panels::user-menu.before') ->navigationGroup('Settings') ->navigationIcon('heroicon-o-globe-alt') ->showFlags(true) ->disableKeyAndGroupEditing(false) ->dontRegisterNavigationOnPanelIds(['guest']) ->prependDirectoryPathToGroupName(false)
Available Configuration Methods
availableLocales(array $locales)- Set available application localesdisableKeyAndGroupEditing(bool $disable = true)- Control key/group editinglanguageSwitcher(bool $enable = true)- Enable/disable language switcherlanguageSwitcherRenderHook(string $hook)- Set render hook for language switchernavigationGroupTranslationKey(?string $key)- Set navigation group translation keynavigationGroup(?string $group)- Set navigation groupnavigationIcon(mixed $icon)- Set navigation icon (supportsfalseto disable)dontRegisterNavigationOnPanelIds(array $panelIds)- Exclude panels from navigationshowFlags(bool $show = true)- Show flags in language switcherprependDirectoryPathToGroupName(bool $prepend = true)- Control group naming
Config File
You can use the following command to publish the configuration file:
php artisan vendor:publish --tag=translation-manager-config
Authorization
By default, the translation manager cannot be used by anyone.
You need to define the following gate in your AppServiceProvider boot method:
// app/Providers/AppServiceProvider.php use Illuminate\Support\Facades\Gate; /** * Bootstrap any application services. */ public function boot(): void { Gate::define('use-translation-manager', function (?User $user) { return $user !== null && $user->hasRole('admin'); }); }
available_locales
Determines which locales your application supports. For example:
'available_locales' => [ ['code' => 'en', 'name' => 'English', 'flag' => 'gb'], ['code' => 'ar', 'name' => 'Arabic', 'flag' => 'sa'], ]
language_switcher
Enable or disable the language switcher feature. This allows users to switch their language - disable if you have your own implementation.
License
The MIT License (MIT). Please see License File for more information.