Skip to content

Commit

Permalink
Make placeholder translatable
Browse files Browse the repository at this point in the history
  • Loading branch information
PhiloNL committed Jun 25, 2021
1 parent 70e2071 commit ce606cb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 25 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ You can register commands by adding these to the `livewire-ui-spotlight.php` con
<?php

return [
'placeholder' => 'What do you want to do?',
'commands' => [
\App\SpotlightCommands\CreateUser::class
]
Expand Down Expand Up @@ -262,7 +261,7 @@ class CreateUser extends SpotlightCommand


## Configuration
You can customize the placeholder for Spotlight via the `livewire-ui-spotlight.php` config file. This includes some additional options like including CSS if you don't use TailwindCSS for your application. To publish the config run the vendor:publish command:
You can customize Spotlight via the `livewire-ui-spotlight.php` config file. This includes some additional options like including CSS if you don't use TailwindCSS for your application. To publish the config run the vendor:publish command:
```shell
php artisan vendor:publish --tag=livewire-ui-spotlight-config
```
Expand All @@ -287,17 +286,6 @@ return [
'slash',
],

/*
|--------------------------------------------------------------------------
| Placeholder
|--------------------------------------------------------------------------
|
| Define the text you want to show by default when Spotlight is enabled
|
*/

'placeholder' => 'What do you want to do?',

/*
|--------------------------------------------------------------------------
| Placeholder
Expand Down Expand Up @@ -339,6 +327,20 @@ return [
];
```

If you want to translate or change default the placeholder you will need to publish the translation file.

```shell
php artisan vendor:publish --tag=livewire-ui-spotlight-translations
```

```php
<?php

return [
'placeholder' => 'What do you want to do?',
];
```

## Credits

- [Philo Hermans](https://github.com/philoNL)
Expand Down
11 changes: 0 additions & 11 deletions config/livewire-ui-spotlight.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@
'slash',
],

/*
|--------------------------------------------------------------------------
| Placeholder
|--------------------------------------------------------------------------
|
| Define the text you want to show by default when Spotlight is enabled
|
*/

'placeholder' => 'What do you want to do?',

/*
|--------------------------------------------------------------------------
| Placeholder
Expand Down
5 changes: 5 additions & 0 deletions resources/lang/en/spotlight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'placeholder' => 'What do you want to do?',
];
2 changes: 1 addition & 1 deletion resources/views/spotlight.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<style>{!! file_get_contents($cssPath) !!}</style>
@endisset

<div x-data="LivewireUISpotlight({ componentId: '{{ $this->id }}', placeholder: '{{ config('livewire-ui-spotlight.placeholder') }}', commands: {{ $commands }} })"
<div x-data="LivewireUISpotlight({ componentId: '{{ $this->id }}', placeholder: '{{ trans('livewire-ui-spotlight::spotlight.placeholder') }}', commands: {{ $commands }} })"
x-init="init()"
x-show="isOpen"
x-cloak
Expand Down
1 change: 1 addition & 0 deletions src/SpotlightServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function configurePackage(Package $package): void
$package
->name('livewire-ui-spotlight')
->hasConfigFile()
->hasTranslations()
->hasViews()
->hasCommand(MakeSpotlightCommand::class);
}
Expand Down

0 comments on commit ce606cb

Please sign in to comment.