mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-09 18:19:27 +01:00
add translations for plugin resource
This commit is contained in:
parent
4194315d4c
commit
736d9be9e3
@ -5,7 +5,6 @@ namespace App\Enums;
|
|||||||
use Filament\Support\Contracts\HasColor;
|
use Filament\Support\Contracts\HasColor;
|
||||||
use Filament\Support\Contracts\HasIcon;
|
use Filament\Support\Contracts\HasIcon;
|
||||||
use Filament\Support\Contracts\HasLabel;
|
use Filament\Support\Contracts\HasLabel;
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
enum PluginStatus: string implements HasColor, HasIcon, HasLabel
|
enum PluginStatus: string implements HasColor, HasIcon, HasLabel
|
||||||
{
|
{
|
||||||
@ -39,6 +38,6 @@ enum PluginStatus: string implements HasColor, HasIcon, HasLabel
|
|||||||
|
|
||||||
public function getLabel(): string
|
public function getLabel(): string
|
||||||
{
|
{
|
||||||
return Str::headline($this->name);
|
return trans('admin/plugin.status_enum.' . $this->value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,21 @@ class PluginResource extends Resource
|
|||||||
|
|
||||||
protected static ?string $recordTitleAttribute = 'name';
|
protected static ?string $recordTitleAttribute = 'name';
|
||||||
|
|
||||||
|
public static function getNavigationLabel(): string
|
||||||
|
{
|
||||||
|
return trans('admin/plugin.nav_title');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getModelLabel(): string
|
||||||
|
{
|
||||||
|
return trans('admin/plugin.model_label');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPluralModelLabel(): string
|
||||||
|
{
|
||||||
|
return trans('admin/plugin.model_label_plural');
|
||||||
|
}
|
||||||
|
|
||||||
public static function getNavigationBadge(): ?string
|
public static function getNavigationBadge(): ?string
|
||||||
{
|
{
|
||||||
return static::getModel()::count() ?: null;
|
return static::getModel()::count() ?: null;
|
||||||
@ -38,30 +53,37 @@ class PluginResource extends Resource
|
|||||||
->defaultSort('load_order')
|
->defaultSort('load_order')
|
||||||
->columns([
|
->columns([
|
||||||
TextColumn::make('name')
|
TextColumn::make('name')
|
||||||
|
->label(trans('admin/plugin.name'))
|
||||||
->description(fn (Plugin $plugin) => (strlen($plugin->description) > 80) ? substr($plugin->description, 0, 80).'...' : $plugin->description)
|
->description(fn (Plugin $plugin) => (strlen($plugin->description) > 80) ? substr($plugin->description, 0, 80).'...' : $plugin->description)
|
||||||
->icon(fn (Plugin $plugin) => $plugin->isUpdateAvailable() ? 'tabler-versions-off' : 'tabler-versions')
|
->icon(fn (Plugin $plugin) => $plugin->isUpdateAvailable() ? 'tabler-versions-off' : 'tabler-versions')
|
||||||
->iconColor(fn (Plugin $plugin) => $plugin->isUpdateAvailable() ? 'danger' : 'success')
|
->iconColor(fn (Plugin $plugin) => $plugin->isUpdateAvailable() ? 'danger' : 'success')
|
||||||
->tooltip(fn (Plugin $plugin) => $plugin->isUpdateAvailable() ? 'An update for this plugin is available' : null)
|
->tooltip(fn (Plugin $plugin) => $plugin->isUpdateAvailable() ? trans('admin/plugin.update_available') : null)
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('author')
|
TextColumn::make('author')
|
||||||
|
->label(trans('admin/plugin.author'))
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('version')
|
TextColumn::make('version')
|
||||||
|
->label(trans('admin/plugin.version'))
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('category')
|
TextColumn::make('category')
|
||||||
|
->label(trans('admin/plugin.category'))
|
||||||
->badge()
|
->badge()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('status')
|
TextColumn::make('status')
|
||||||
|
->label(trans('admin/plugin.status'))
|
||||||
->badge()
|
->badge()
|
||||||
->tooltip(fn (Plugin $plugin) => $plugin->status_message)
|
->tooltip(fn (Plugin $plugin) => $plugin->status_message)
|
||||||
->sortable(),
|
->sortable(),
|
||||||
])
|
])
|
||||||
->actions([
|
->actions([
|
||||||
Action::make('view')
|
Action::make('view')
|
||||||
|
->label(trans('filament-actions::view.single.label'))
|
||||||
->icon('tabler-eye-share')
|
->icon('tabler-eye-share')
|
||||||
->color('gray')
|
->color('gray')
|
||||||
->visible(fn (Plugin $plugin) => $plugin->url)
|
->visible(fn (Plugin $plugin) => $plugin->url)
|
||||||
->url(fn (Plugin $plugin) => $plugin->url, true),
|
->url(fn (Plugin $plugin) => $plugin->url, true),
|
||||||
Action::make('settings')
|
Action::make('settings')
|
||||||
|
->label(trans('admin/plugin.settings'))
|
||||||
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
||||||
->icon('tabler-settings')
|
->icon('tabler-settings')
|
||||||
->color('primary')
|
->color('primary')
|
||||||
@ -70,6 +92,7 @@ class PluginResource extends Resource
|
|||||||
->action(fn (array $data, Plugin $plugin) => $plugin->saveSettings($data))
|
->action(fn (array $data, Plugin $plugin) => $plugin->saveSettings($data))
|
||||||
->slideOver(),
|
->slideOver(),
|
||||||
Action::make('install')
|
Action::make('install')
|
||||||
|
->label(trans('admin/plugin.install'))
|
||||||
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
||||||
->icon('tabler-terminal')
|
->icon('tabler-terminal')
|
||||||
->color('success')
|
->color('success')
|
||||||
@ -81,10 +104,11 @@ class PluginResource extends Resource
|
|||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->success()
|
->success()
|
||||||
->title('Plugin installed')
|
->title(trans('admin/plugin.notifications.installed'))
|
||||||
->send();
|
->send();
|
||||||
}),
|
}),
|
||||||
Action::make('update')
|
Action::make('update')
|
||||||
|
->label(trans('admin/plugin.update'))
|
||||||
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
||||||
->icon('tabler-download')
|
->icon('tabler-download')
|
||||||
->color('success')
|
->color('success')
|
||||||
@ -96,10 +120,11 @@ class PluginResource extends Resource
|
|||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->success()
|
->success()
|
||||||
->title('Plugin updated')
|
->title(trans('admin/plugin.notifications.updated'))
|
||||||
->send();
|
->send();
|
||||||
}),
|
}),
|
||||||
Action::make('enable')
|
Action::make('enable')
|
||||||
|
->label(trans('admin/plugin.enable'))
|
||||||
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
||||||
->icon('tabler-check')
|
->icon('tabler-check')
|
||||||
->color('success')
|
->color('success')
|
||||||
@ -114,10 +139,11 @@ class PluginResource extends Resource
|
|||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->success()
|
->success()
|
||||||
->title('Plugin enabled')
|
->title(trans('admin/plugin.notifications.updated'))
|
||||||
->send();
|
->send();
|
||||||
}),
|
}),
|
||||||
Action::make('disable')
|
Action::make('disable')
|
||||||
|
->label(trans('admin/plugin.disable'))
|
||||||
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
->authorize(fn (Plugin $plugin) => auth()->user()->can('update', $plugin))
|
||||||
->icon('tabler-x')
|
->icon('tabler-x')
|
||||||
->color('danger')
|
->color('danger')
|
||||||
@ -129,19 +155,20 @@ class PluginResource extends Resource
|
|||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->success()
|
->success()
|
||||||
->title('Plugin disabled')
|
->title(trans('admin/plugin.notifications.updated'))
|
||||||
->send();
|
->send();
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
->headerActions([
|
->headerActions([
|
||||||
Action::make('download')
|
Action::make('import')
|
||||||
|
->label(trans('admin/plugin.import'))
|
||||||
->authorize(fn (Plugin $plugin) => auth()->user()->can('create', $plugin))
|
->authorize(fn (Plugin $plugin) => auth()->user()->can('create', $plugin))
|
||||||
->icon('tabler-download')
|
->icon('tabler-download')
|
||||||
->form([
|
->form([
|
||||||
Tabs::make('Tabs')
|
Tabs::make('Tabs')
|
||||||
->contained(false)
|
->contained(false)
|
||||||
->tabs([
|
->tabs([
|
||||||
Tab::make('From File')
|
Tab::make(trans('admin/plugin.from_file'))
|
||||||
->icon('tabler-file-upload')
|
->icon('tabler-file-upload')
|
||||||
->schema([
|
->schema([
|
||||||
FileUpload::make('file')
|
FileUpload::make('file')
|
||||||
@ -150,7 +177,7 @@ class PluginResource extends Resource
|
|||||||
->previewable(false)
|
->previewable(false)
|
||||||
->storeFiles(false),
|
->storeFiles(false),
|
||||||
]),
|
]),
|
||||||
Tab::make('From URL')
|
Tab::make(trans('admin/plugin.from_url'))
|
||||||
->icon('tabler-world-upload')
|
->icon('tabler-world-upload')
|
||||||
->schema([
|
->schema([
|
||||||
TextInput::make('url')
|
TextInput::make('url')
|
||||||
@ -173,14 +200,14 @@ class PluginResource extends Resource
|
|||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->success()
|
->success()
|
||||||
->title('Plugin downloaded')
|
->title(trans('admin/plugin.notifications.downloaded'))
|
||||||
->send();
|
->send();
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
report($exception);
|
report($exception);
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->danger()
|
->danger()
|
||||||
->title('Could not download plugin.')
|
->title(trans('admin/plugin.notifications.download_failed'))
|
||||||
->body($exception->getMessage())
|
->body($exception->getMessage())
|
||||||
->send();
|
->send();
|
||||||
}
|
}
|
||||||
@ -188,7 +215,7 @@ class PluginResource extends Resource
|
|||||||
])
|
])
|
||||||
->emptyStateIcon('tabler-packages')
|
->emptyStateIcon('tabler-packages')
|
||||||
->emptyStateDescription('')
|
->emptyStateDescription('')
|
||||||
->emptyStateHeading('No Plugins');
|
->emptyStateHeading(trans('admin/plugin.no_plugins'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
|
|||||||
40
lang/en/admin/plugin.php
Normal file
40
lang/en/admin/plugin.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'nav_title' => 'Plugins',
|
||||||
|
'model_label' => 'Plugin',
|
||||||
|
'model_label_plural' => 'Plugins',
|
||||||
|
|
||||||
|
'name' => 'Name',
|
||||||
|
'update_available' => 'An update for this plugin is available',
|
||||||
|
'author' => 'Author',
|
||||||
|
'version' => 'Version',
|
||||||
|
'category' => 'Category',
|
||||||
|
'status' => 'Status',
|
||||||
|
'settings' => 'Settings',
|
||||||
|
'install' => 'Install',
|
||||||
|
'update' => 'Update',
|
||||||
|
'enable' => 'Enable',
|
||||||
|
'disable' => 'Disable',
|
||||||
|
'import' => 'Import',
|
||||||
|
'no_plugins' => 'No Plugins',
|
||||||
|
'from_file' => 'From File',
|
||||||
|
'from_url' => 'From URL',
|
||||||
|
|
||||||
|
'status_enum' => [
|
||||||
|
'not_installed' => 'Not Installed',
|
||||||
|
'disabled' => 'Disabled',
|
||||||
|
'enabled' => 'Enabled',
|
||||||
|
'errored' => 'Errored',
|
||||||
|
'incompatible' => 'Incompatible',
|
||||||
|
],
|
||||||
|
|
||||||
|
'notifications' => [
|
||||||
|
'installed' => 'Plugin installed',
|
||||||
|
'updated' => 'Plugin updated',
|
||||||
|
'enabled' => 'Plugin enabled',
|
||||||
|
'disabled' => 'Plugin disabled',
|
||||||
|
'downloaded' => 'Plugin downloaded',
|
||||||
|
'download_failed' => 'Could not download plugin',
|
||||||
|
],
|
||||||
|
];
|
||||||
Loading…
x
Reference in New Issue
Block a user