by Kenepa
Introducing Filament translation manager, a tool that lets you manage, preview, and sync translations with your language files in the dashboard.
Introducing our Filament translation management tool, which allows you to easily manage, preview, and sync translations with your language files all within your Filament admin dashboard. Say goodbye to relying on developers to edit language files and streamline your localization workflow today.
You can install the package via composer:
composer require kenepa/translation-manager
You can run the following command to publish the configuration file:
php artisan vendor:publish --tag=translation-manager-config
This package uses spatie/laravel-translation-loader
, publish their migration file using:
php artisan vendor:publish --provider="Spatie\TranslationLoader\TranslationServiceProvider" --tag="migrations"
You have to update the migration file to the following:
Schema::create('language_lines', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('group')->index(); $table->string('key')->index(); $table->json('text')->default('[]'); $table->timestamps();});
Finally, run the migration.
If you want to make use of the language switcher, you have to enable the middleware.
First in app/Http/Kernel.php
under the 'web' middleware group:
protected $middlewareGroups = [ 'web' => [ // ... // Add the middleware to the array \Kenepa\TranslationManager\Http\Middleware\SetLanguage::class, ]];
Secondly in config/filament.php
:
'middleware' => [ 'auth' => [/* ... */], 'base' => [ // ... // Add the middleware to the array \Kenepa\TranslationManager\Http\Middleware\SetLanguage::class, ]]
By default, the translation manager cannot be used by anyone. You need to define the following gate in your AppServiceProvider
boot method:
Gate::define('use-translation-manager', function (?User $user) { // Your authorization logic return $user !== null && $user->hasRole('admin');});
available_locales
Determines which locales your application supports. For example:
'available_locales' => [ ['code' => 'en', 'name' => 'English', 'emoji' => '🇬🇧'], ['code' => 'nl', 'name' => 'Nederlands', 'emoji' => '🇳🇱'], ['code' => 'de', 'name' => 'Deutsch', 'emoji' => '🇩🇪']]
language_switcher
Enable or disable the language switcher feature. This allows users to switch their language - disable if you have your own implementation.
Once installed, the Translation Manager can be accessed via the Filament sidebar menu. Simply click on the "Translation Manager" link to access the translation management screen.
The MIT License (MIT). Please see License File for more information.