Add Import and Export Functionality for Site Translations: Implemented SiteTranslationImporter and SiteTranslationExporter classes to facilitate the import and export of site translations. Enhanced the SiteTranslationsTable with import and export actions, allowing for efficient management of translation data. Updated the migration files to create necessary tables for handling imports and exports, improving the overall localization workflow in the admin panel.

This commit is contained in:
Ümit Tunç
2025-12-31 00:23:16 +03:00
parent 2c9dcac76c
commit 922add1b6f
7 changed files with 348 additions and 77 deletions
@@ -8,6 +8,14 @@ use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use App\Models\Language;
use Filament\Forms\Components\Textarea;
use Filament\Schemas\Components\Group;
use Filament\Schemas\Components\Section;
use Filament\Actions\ImportAction;
use Filament\Actions\ExportAction;
use App\Filament\Imports\SiteTranslationImporter;
use App\Filament\Exports\SiteTranslationExporter;
class SiteTranslationsTable
{
@@ -16,6 +24,12 @@ class SiteTranslationsTable
$defaultLocale = app()->getLocale();
return $table
->headerActions([
ImportAction::make()
->importer(SiteTranslationImporter::class),
ExportAction::make()
->exporter(SiteTranslationExporter::class)
])
->columns([
TextColumn::make('key')
->searchable()
@@ -39,7 +53,34 @@ class SiteTranslationsTable
//
])
->recordActions([
EditAction::make(),
EditAction::make()
->modalWidth('xl')
->form(function () {
$languages = Language::where('is_active', true)->get();
$translationFields = [];
foreach ($languages as $language) {
$translationFields[] = Textarea::make($language->code)
->label($language->name . " ({$language->code})")
->rows(2);
}
return [
Section::make()
->schema([
Textarea::make('key')
->label('Key / Original Text')
->required()
->columnSpanFull()
->helperText('The original text to be translated. Use this exact text in t() helper.'),
Group::make()
->schema($translationFields)
->statePath('translations')
->columnSpanFull(),
])
];
}),
DeleteAction::make(),
])
->toolbarActions([