blackbadge-studio / translation-editor
A Filament plugin that allows editing application translations directly in context via a modal or floating UI.
Fund package maintenance!
blackbadge-studio
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/blackbadge-studio/translation-editor
Requires
- php: ^8.2
- filament/filament: ^4.0
- spatie/laravel-package-tools: ^1.15.0
- spatie/laravel-translation-loader: ^2.8
- wedesignit/laravel-translations-import: ^1.1
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- pestphp/pest-plugin-livewire: ^3.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- rector/rector: ^2.0
- spatie/laravel-ray: ^1.26
This package is not auto-updated.
Last update: 2026-01-21 21:02:17 UTC
README
This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
Installation
You can install the package via composer:
composer require blackbadge-studio/translation-editor
Important
If you have not set up a custom theme and are using Filament Panels follow the instructions in the Filament Docs first.
After setting up a custom theme add the plugin's views to your theme css file or your app's css file if using the standalone packages.
@source '../../../../vendor/blackbadge-studio/translation-editor/resources/**/*.blade.php';
You can publish and run the migrations with:
php artisan vendor:publish --tag="translation-editor-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="translation-editor-config"
Register the plugin in your Filament panel configuration (usually in app/Providers/Filament/AdminPanelProvider.php or similar):
use Blackbadgestudio\TranslationEditor\TranslationEditorPlugin; public function panel(Panel $panel): Panel { return $panel // ... other configuration ->plugins([ TranslationEditorPlugin::make(), // ... other plugins ]); }
Optionally, you can publish the views using
php artisan vendor:publish --tag="translation-editor-views"
This is the contents of the published config file:
<?php return [ /* |-------------------------------------------------------------------------- | Model configuration |-------------------------------------------------------------------------- | | Configure which Eloquent models / sources are used for translations | and locales. | */ 'models' => [ // The model that represents your translatable strings. This should // extend Spatie\TranslationLoader\LanguageLine. 'translation' => 'Spatie\\TranslationLoader\\LanguageLine', // The configuration that represents your locales. // // Supported values: // - an array of locale codes: ['en', 'fr'] // - an array with a model configuration: // ['model' => App\Models\Locale::class, 'column' => 'code'] // - a model class string that has a `key` (or configured) column. // // Example using a locales table: // 'locale' => [ // 'model' => 'App\\Models\\Locale', // 'column' => 'code', // ], 'locale' => [ 'en', 'nl', 'fr', ], ], /* |-------------------------------------------------------------------------- | Translation loader configuration |-------------------------------------------------------------------------- | | Configure how the package integrates with spatie/laravel-translation-loader. | These values will be applied to the `translation-loader` config at runtime. | You can override them in your own app config if needed. | */ 'translation_loader' => [ // The translation loaders to register with spatie/laravel-translation-loader. // By default we use the tracking DB loader that works with TranslationTracker. 'translation_loaders' => [ App\TranslationLoaders\TrackingDbLoader::class, ], // The translation manager class which overrides the default Laravel // `translation.loader`. 'translation_manager' => App\TranslationLoaders\TrackingTranslationLoaderManager::class, ], /* |-------------------------------------------------------------------------- | Authenticatable model locale column |-------------------------------------------------------------------------- | | Configure how the package determines where to store the user's locale. | | By default it will use the configured user model and its table: | config('auth.providers.users.model') | | Supported options: | - 'model': The Authenticatable model class (e.g. App\Models\User::class) | - 'table': The table name (if you want to override the model's table) | - 'column': The column name for the locale (defaults to 'locale') | - 'toggle_column': The column name for enabling/disabling the modal (defaults to 'translation_modal_enabled') */ 'auth' => [ 'model' => 'App\\Models\\User', 'table' => 'users', 'column' => 'locale', 'toggle_column' => 'translation_modal_enabled', ], ];
Usage
Adding the Translation Editor Action
You can easily add a toggle action to any Filament resource to enable/disable the translation editor modal for users. Simply use the provided action class:
use Blackbadgestudio\TranslationEditor\Actions\TranslationEditorAction; use Filament\Resources\Resource; class UserResource extends Resource { // ... public static function getHeaderActions(): array { return [ TranslationEditorAction::make(), // ... other actions ]; } }
The action will automatically:
- Show "Enable Translation Editor" or "Disable Translation Editor" based on the current state
- Display the appropriate icon (eye/eye-slash)
- Use success/danger colors accordingly
- Show a notification when toggled
- Use the configured
toggle_columnfrom your config file
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.