
The first and only automatic Filament localization package with intelligent resource scanning, structured translation files, and comprehensive testing. This package eliminates the repetitive task of manually adding translation keys to every field, column, action, and component in your Filament application.
This is the original and only package that provides automatic localization with translation features for Filament.
Requirements: PHP ^8.2|^8.3|^8.4 | Laravel ^12.0 | Filament ^4.0
🆕 Latest Updates: Enhanced DeepL integration with smart translation detection, page localization support, and intelligent skip terms configuration.
Install the package via Composer (automatically installs all dependencies):
composer require mominalzaraa/filament-localization
Publish the configuration file:
php artisan vendor:publish --tag="filament-localization-config"
The configuration file config/filament-localization.php provides customization options:
return [ 'default_locale' => 'en', 'locales' => ['en', 'es', 'fr'], 'structure' => 'panel-based', // flat, nested, or panel-based 'backup' => true, 'git' => [ 'enabled' => true, 'commit_message' => 'chore: add Filament localization support', ], 'excluded_panels' => [], 'excluded_resources' => [], 'translation_key_prefix' => 'filament', // Skip Terms - Terms that should remain the same across languages 'skip_identical_terms' => [ 'API', 'URL', 'HTTP', 'HTTPS', 'PDF', 'CSV', 'JSON', 'XML', 'Laravel', 'Filament', 'Vue', 'React', 'Angular', 'Google', 'Microsoft', 'GitHub', 'Docker', 'AWS', 'Azure', 'PayPal', 'Stripe', 'WordPress', 'Bootstrap', 'Tailwind', 'jQuery', 'TypeScript', 'Webpack', 'Vite', 'JWT', 'OAuth', 'REST', 'GraphQL', 'SEO', 'UX', 'UI', 'SaaS', 'PaaS', 'IoT', 'AI', 'ML', 'DevOps', 'CI/CD', 'Agile', 'Scrum', 'TDD', 'BDD', 'GDPR', 'ISO', 'IEEE', 'W3C', 'OWASP', 'NIST', 'ITIL', 'PMP', ], // DeepL Translation Configuration 'deepl' => [ 'api_key' => env('DEEPL_API_KEY'), 'base_url' => env('DEEPL_BASE_URL', 'https://api-free.deepl.com/v2'), 'timeout' => 60, 'batch_size' => 50, 'preserve_formatting' => true, ],];
The package provides two commands for localization and translation:
filament:localize - Main Localization CommandScans and localizes Filament resources with structured translation files.
# Basic usagephp artisan filament:localize # Specific panels and localesphp artisan filament:localize --panel=admin --locale=en --locale=es # Preview changesphp artisan filament:localize --dry-run # Force update existing labelsphp artisan filament:localize --force # Skip git commitphp artisan filament:localize --no-git
Options:
--panel=* - Specific panel(s) to localize--locale=* - Specific locale(s) to generate--force - Force localization even if labels exist--no-git - Skip git commit--dry-run - Preview changes without applying themfilament:translate-with-deepl - DeepL Translation CommandIntelligently translates Filament resources using the DeepL API with smart detection of untranslated content.
Prerequisites:
.env file: DEEPL_API_KEY=your_deepl_api_key_here
# Smart translation - detects untranslated content automaticallyphp artisan filament:translate-with-deepl --source-lang=en --target-lang=es --panel=admin # Force mode - overwrites all existing translationsphp artisan filament:translate-with-deepl --source-lang=en --target-lang=fr --panel=admin --force # Multiple panels with previewphp artisan filament:translate-with-deepl --source-lang=en --target-lang=de --panel=admin --panel=blog --dry-run
Features:
--force
Options:
--source-lang=SOURCE-LANG - Source language code (default: "en")--target-lang=TARGET-LANG - Target language code (required)--panel=PANEL - Specific panel(s) to translate--force - Force translation and overwrite all existing translations--dry-run - Preview changes without applying themSupported Languages: 40+ languages including English, Spanish, French, German, Italian, Portuguese, Russian, Japanese, Chinese, Arabic, and more.
Generate translation files:
php artisan filament:localize --panel=admin
Translate with DeepL (optional):
php artisan filament:translate-with-deepl --source-lang=en --target-lang=es --panel=admin
Install language switcher:
composer require craft-forge/filament-language-switcher
Configure in your panel provider:
FilamentLanguageSwitcherPlugin::make() ->locales([ ['code' => 'en', 'name' => 'English', 'flag' => 'gb'], ['code' => 'es', 'name' => 'Spanish', 'flag' => 'es'], ])
The package creates organized translation files based on your configuration:
Panel-Based Structure (Recommended):
lang/├── en/filament/admin/user_resource.php├── en/filament/blog/post_resource.php└── es/filament/admin/user_resource.php
Other Structures: Nested or flat structures available via configuration.
Automatically removes hardcoded labels and replaces them with translation keys:
// Beforeprotected static ?string $modelLabel = 'Articles'; // Afterprotected static ?string $modelLabel = null; public static function getModelLabel(): string{ return __('filament/admin/user_resource.model_label');}
--force
Now supports Filament pages with static properties and methods:
// Beforeclass Dashboard extends BaseDashboard{ protected static ?string $title = 'Blog Dashboard'; protected static ?string $navigationLabel = 'Dashboard';} // Afterclass Dashboard extends BaseDashboard{ protected static ?string $title = null; protected static ?string $navigationLabel = null; public function getTitle(): string { return __('filament/admin/dashboard.title'); } public static function getNavigationLabel(): string { return __('filament/admin/dashboard.navigation_label'); }}
The DeepL translation command intelligently detects what needs to be translated:
Normal Mode (Default):
skip_identical_terms (e.g., "SMS", "API", "URL")Force Mode (--force):
Example Scenarios:
// Source (English)return [ 'title' => 'Blog Dashboard', 'navigation_label' => 'Send Email', 'description' => 'Manage your blog posts and comments',]; // Target (Spanish) - Before Translationreturn [ 'title' => 'Blog Dashboard', // ← Will be translated (identical to source) 'navigation_label' => 'Send Email', // ← Will be translated (not in skip terms) 'description' => 'Gestiona tus publicaciones', // ← Will be preserved (properly translated)]; // Target (Spanish) - After Translationreturn [ 'title' => 'Panel de Blog', // ← Translated 'navigation_label' => 'Enviar Email', // ← Translated 'description' => 'Gestiona tus publicaciones', // ← Preserved];
This package generates translation files. To enable language switching in your Filament panels, install a language switcher plugin:
Recommended: craft-forge/filament-language-switcher
composer require craft-forge/filament-language-switcher
Configure in your panel provider:
use CraftForge\FilamentLanguageSwitcher\FilamentLanguageSwitcherPlugin; public function panel(Panel $panel): Panel{ return $panel ->plugins([ FilamentLanguageSwitcherPlugin::make() ->locales([ ['code' => 'en', 'name' => 'English', 'flag' => 'gb'], ['code' => 'es', 'name' => 'Spanish', 'flag' => 'es'], ]), ]);}
Other options: filament/spatie-laravel-translatable-plugin, awcodes/filament-language-switcher
The Filament admin interface displays in English with hardcoded labels:
Users list page showing English labels
User edit form with English field labels
File structure showing only English translation files
The same interface now supports multiple languages with proper translation keys:
Users list page with localized Spanish labels
User edit form with localized Spanish field labels
File structure showing organized translation files for multiple locales
Before Localization:
TextInput::make('name')->required(),TextColumn::make('email')->searchable(),Action::make('delete')->requiresConfirmation(),
After Localization:
TextInput::make('name') ->label(__('filament/admin/user_resource.name')) ->required(), TextColumn::make('email') ->label(__('filament/admin/user_resource.email')) ->searchable(), Action::make('delete') ->label(__('filament/admin/user_resource.delete')) ->requiresConfirmation(),
Translation Files Created:
// lang/en/filament/admin/user_resource.phpreturn ['name' => 'Name', 'email' => 'Email', 'delete' => 'Delete']; // lang/es/filament/admin/user_resource.phpreturn ['name' => 'Nombre', 'email' => 'Email', 'delete' => 'Eliminar'];
git reset --soft HEAD~1)composer test
Contributions are welcome! Please feel free to submit a Pull Request.
If this package has helped you, please consider supporting its development:
The MIT License (MIT). Please see License File for more information.