Manage your translation with DB and cache, you can scan your languages tags like trans()
, __()
, and get the string inside and translate them use UI.
this plugin is build in spatie/laravel-translation-loader
composer require tomatophp/filament-translations
Finally reigster the plugin on /app/Providers/Filament/AdminPanelProvider.php
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make())
If you want to use ChatGPT to auto-translate your languages, you need to install OpenAI
package by running:
composer require openai-php/laravel
now you need to add the following to your .env
file:
OPENAI_API_KEY=OPENAI_ORGANIZATION=
allow the feature on your panel provider by adding the following:
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make()->allowGPTScan())
If you want to use Google Translate for auto-translating your languages, you need to install the stichoza/google-translate
package by running:
composer require stichoza/google-translate-php
Enable the feature on your admin panel provider file by adding the following:
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make()->allowGoogleTranslateScan())
If you want to allow the user to create a new language, you need to add the following to your panel provider:
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make()->allowCreate())
If you want to allow the user to clear all translations, you need to add the following to your panel provider:
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsPlugin::make()->allowClearTranslations())
You can publish the resource to your project using:
php artisan vendor:publish --tag="filament-translations-migrations"
If you need to publish config run:
php artisan vendor:publish --tag="filament-translations-config"
Run migration:
php artisan migrate
and now clear cache running:
php artisan optimize:clear
You can publish views file by use this command:
php artisan vendor:publish --tag="filament-translations-views"
You can publish languages file by use this command:
php artisan vendor:publish --tag="filament-translations-lang"
You can publish migrations file by use this command:
php artisan vendor:publish --tag="filament-translations-migrations"
You can use the language switcher in your panel by using the following plugin:
$panel->plugin(\TomatoPHP\FilamentTranslations\FilamentTranslationsSwitcherPlugin::make())
NOTE your auth user table must have lang
filed on the table to make this switch working fine.
You can scan your project to get all the languages tags and save them to the database
php artisan filament-translations:import
In your config file just change the use_queue_on_scan
to true
 'use_queue_on_scan' => true,
You can create your own command to import the translations, add your custom import class to the config file like this:
'path_to_custom_import_command' => ImportTranslations::class,
This command will automatically run when you click on the "Scan For New Languages" button in the UI.
You can create your own Excel import to import the translations, add your custom import class to the config file like this:
'path_to_custom_excel_import' => CustomTranslationImport::class,
The import class is based on the Laravel Excel package. You can check the documentation here. This import will automatically run when you click on the "Import" button in the UI.
You can create your own Excel export to export the translations in your own format, add your custom export class to the config file like this:
'path_to_custom_excel_export' => CustomTranslationExport::class,
The export class is based on the Laravel Excel package. You can check the documentation here. This import will automatically run when you click on the "Export" button in the UI.
You can show or hide the buttons in the UI by changing the config file. By default, all buttons are shown.
'show_import_button' => true,'show_export_button' => false,'show_scan_button' => false ,
You can create your own resource to show the translations in the UI, add your custom resource class to the config file like this:
'translation_resource' => CustomResource::class,
This is especially useful when you want to have complete control over the UI but still want to use the translations package. Think about implementing a check on user roles when using shouldRegisterNavigation
in your custom resource.
you can join our discord server to get support TomatoPHP
you can check docs of this package on Docs
Please see CHANGELOG for more information on what has changed recently.
Please see SECURITY for more information about security.
The MIT License (MIT). Please see License File for more information.