From 3582a6effebaf65057d15615f855e805b5fa03f7 Mon Sep 17 00:00:00 2001 From: Dennis Koch Date: Mon, 18 Nov 2024 20:58:35 +0800 Subject: [PATCH] use lang files --- resources/lang/de/spotlight.php | 6 ++++++ resources/lang/en/spotlight.php | 6 ++++++ src/Actions/RegisterUserMenu.php | 4 ++-- src/Commands/ResourceCommand.php | 4 +++- src/SpotlightPlugin.php | 1 + src/SpotlightServiceProvider.php | 2 ++ 6 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 resources/lang/de/spotlight.php create mode 100644 resources/lang/en/spotlight.php diff --git a/resources/lang/de/spotlight.php b/resources/lang/de/spotlight.php new file mode 100644 index 0000000..be5b67b --- /dev/null +++ b/resources/lang/de/spotlight.php @@ -0,0 +1,6 @@ + 'Nach :Record suchen', + 'account' => 'Dein Konto', +]; diff --git a/resources/lang/en/spotlight.php b/resources/lang/en/spotlight.php new file mode 100644 index 0000000..5cec683 --- /dev/null +++ b/resources/lang/en/spotlight.php @@ -0,0 +1,6 @@ + 'Search for a :record', + 'account' => 'Your account', +]; diff --git a/src/Actions/RegisterUserMenu.php b/src/Actions/RegisterUserMenu.php index 37aefb0..9b33673 100644 --- a/src/Actions/RegisterUserMenu.php +++ b/src/Actions/RegisterUserMenu.php @@ -38,8 +38,8 @@ public static function boot(Panel $panel) protected function getName(string $key, MenuItem $item): ?string { return match ($key) { - 'account' => $item->getLabel() ?? __('Your Account'), - 'logout' => $item->getLabel() ?? __('filament::layout.buttons.logout.label'), + 'account' => $item->getLabel() ?? __('filament-spotlight::spotlight.account'), + 'logout' => $item->getLabel() ?? __('filament-panels::layout.actions.logout.label'), default => $item->getLabel() }; } diff --git a/src/Commands/ResourceCommand.php b/src/Commands/ResourceCommand.php index 3511217..5ec5bcf 100644 --- a/src/Commands/ResourceCommand.php +++ b/src/Commands/ResourceCommand.php @@ -86,7 +86,9 @@ public function dependencies(): ?SpotlightCommandDependencies } return SpotlightCommandDependencies::collection()->add( - SpotlightCommandDependency::make('record')->setPlaceholder(__('Search for a :record', ['record' => $this->resource::getModelLabel()])) + SpotlightCommandDependency::make('record')->setPlaceholder( + __('filament-spotlight::spotlight.placeholder', ['record' => $this->resource::getModelLabel()]) + ) ); } diff --git a/src/SpotlightPlugin.php b/src/SpotlightPlugin.php index 6ae5e26..af56430 100644 --- a/src/SpotlightPlugin.php +++ b/src/SpotlightPlugin.php @@ -38,6 +38,7 @@ public function boot(Panel $panel): void { Filament::serving(function () use ($panel) { config()->set('livewire-ui-spotlight.include_js', false); + if (Filament::hasTenancy()) { Event::listen(TenantSet::class, function () use ($panel) { self::registerNavigation($panel); diff --git a/src/SpotlightServiceProvider.php b/src/SpotlightServiceProvider.php index 59425c1..9f439d9 100644 --- a/src/SpotlightServiceProvider.php +++ b/src/SpotlightServiceProvider.php @@ -11,6 +11,8 @@ class SpotlightServiceProvider extends ServiceProvider { public function boot() { + $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'filament-spotlight'); + config()->set('livewire-ui-spotlight.commands', []); FilamentAsset::register([