Add localization support for Pages in Filament admin panel: Introduced language files for English and Turkish, added translation methods for page titles and notifications in Create, Edit, and List pages, enhancing user experience and accessibility.
This commit is contained in:
@@ -22,6 +22,21 @@ class PageResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedDocumentText;
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('pages.navigation_label');
|
||||
}
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return __('pages.model_label');
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return __('pages.plural_model_label');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return PageForm::configure($schema);
|
||||
|
||||
@@ -8,4 +8,19 @@ use Filament\Resources\Pages\CreateRecord;
|
||||
class CreatePage extends CreateRecord
|
||||
{
|
||||
protected static string $resource = PageResource::class;
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return __('pages.create');
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('index');
|
||||
}
|
||||
|
||||
protected function getCreatedNotificationTitle(): ?string
|
||||
{
|
||||
return __('pages.created_successfully');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,30 @@ class EditPage extends EditRecord
|
||||
{
|
||||
protected static string $resource = PageResource::class;
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return __('pages.edit');
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
ForceDeleteAction::make(),
|
||||
RestoreAction::make(),
|
||||
DeleteAction::make()
|
||||
->label(__('pages.delete')),
|
||||
ForceDeleteAction::make()
|
||||
->label(__('pages.force_delete')),
|
||||
RestoreAction::make()
|
||||
->label(__('pages.restore')),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getRedirectUrl(): string
|
||||
{
|
||||
return $this->getResource()::getUrl('index');
|
||||
}
|
||||
|
||||
protected function getSavedNotificationTitle(): ?string
|
||||
{
|
||||
return __('pages.updated_successfully');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,16 @@ class ListPages extends ListRecords
|
||||
{
|
||||
protected static string $resource = PageResource::class;
|
||||
|
||||
public function getTitle(): string
|
||||
{
|
||||
return __('pages.title');
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
CreateAction::make()
|
||||
->label(__('pages.create')),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => 'Pages',
|
||||
'navigation_label' => 'Pages',
|
||||
'model_label' => 'Page',
|
||||
'plural_model_label' => 'Pages',
|
||||
|
||||
// Actions
|
||||
'create' => 'Create New Page',
|
||||
'edit' => 'Edit Page',
|
||||
'delete' => 'Delete Page',
|
||||
'restore' => 'Restore Page',
|
||||
'force_delete' => 'Force Delete',
|
||||
|
||||
// Form fields
|
||||
'title_field' => 'Title',
|
||||
'slug_field' => 'URL Slug',
|
||||
'content_field' => 'Content',
|
||||
'meta_title_field' => 'Meta Title',
|
||||
'meta_description_field' => 'Meta Description',
|
||||
'status_field' => 'Status',
|
||||
'published_at_field' => 'Published At',
|
||||
|
||||
// Status options
|
||||
'status_draft' => 'Draft',
|
||||
'status_published' => 'Published',
|
||||
'status_archived' => 'Archived',
|
||||
|
||||
// Messages
|
||||
'created_successfully' => 'Page created successfully.',
|
||||
'updated_successfully' => 'Page updated successfully.',
|
||||
'deleted_successfully' => 'Page deleted successfully.',
|
||||
'restored_successfully' => 'Page restored successfully.',
|
||||
|
||||
// Table columns
|
||||
'table_title' => 'Title',
|
||||
'table_slug' => 'URL Slug',
|
||||
'table_status' => 'Status',
|
||||
'table_created_at' => 'Created At',
|
||||
'table_updated_at' => 'Updated At',
|
||||
|
||||
// Validation messages
|
||||
'title_required' => 'The title field is required.',
|
||||
'slug_required' => 'The URL slug field is required.',
|
||||
'slug_unique' => 'This URL slug is already taken.',
|
||||
'content_required' => 'The content field is required.',
|
||||
];
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'title' => 'Sayfalar',
|
||||
'navigation_label' => 'Sayfalar',
|
||||
'model_label' => 'Sayfa',
|
||||
'plural_model_label' => 'Sayfalar',
|
||||
|
||||
// Actions
|
||||
'create' => 'Yeni Sayfa Oluştur',
|
||||
'edit' => 'Sayfayı Düzenle',
|
||||
'delete' => 'Sayfayı Sil',
|
||||
'restore' => 'Sayfayı Geri Yükle',
|
||||
'force_delete' => 'Kalıcı Olarak Sil',
|
||||
|
||||
// Form fields
|
||||
'title_field' => 'Başlık',
|
||||
'slug_field' => 'URL Yolu',
|
||||
'content_field' => 'İçerik',
|
||||
'meta_title_field' => 'Meta Başlık',
|
||||
'meta_description_field' => 'Meta Açıklama',
|
||||
'status_field' => 'Durum',
|
||||
'published_at_field' => 'Yayın Tarihi',
|
||||
|
||||
// Status options
|
||||
'status_draft' => 'Taslak',
|
||||
'status_published' => 'Yayınlandı',
|
||||
'status_archived' => 'Arşivlendi',
|
||||
|
||||
// Messages
|
||||
'created_successfully' => 'Sayfa başarıyla oluşturuldu.',
|
||||
'updated_successfully' => 'Sayfa başarıyla güncellendi.',
|
||||
'deleted_successfully' => 'Sayfa başarıyla silindi.',
|
||||
'restored_successfully' => 'Sayfa başarıyla geri yüklendi.',
|
||||
|
||||
// Table columns
|
||||
'table_title' => 'Başlık',
|
||||
'table_slug' => 'URL Yolu',
|
||||
'table_status' => 'Durum',
|
||||
'table_created_at' => 'Oluşturulma Tarihi',
|
||||
'table_updated_at' => 'Güncellenme Tarihi',
|
||||
|
||||
// Validation messages
|
||||
'title_required' => 'Başlık alanı zorunludur.',
|
||||
'slug_required' => 'URL yolu alanı zorunludur.',
|
||||
'slug_unique' => 'Bu URL yolu zaten kullanılıyor.',
|
||||
'content_required' => 'İçerik alanı zorunludur.',
|
||||
];
|
||||
Reference in New Issue
Block a user