Reputation: 1681
Actually, I need to change the laravel nova action name like translate into different languages.
class PrintWithDetail extends Action
{
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Perform the action on the given models.
*
* @param \Laravel\Nova\Fields\ActionFields $fields
* @param \Illuminate\Support\Collection $models
* @return mixed
*/
public function handle(ActionFields $fields, Collection $models)
{
$id = '';
//
foreach ($models as $model) {
$id = $model->id;
}
return Action::openInNewTab(route("print.work.order", [$id, 'type' => 'detail']));
}
}
Above action show PrintWithDetail as name.
But, I need to change PrintWithDetail into dutch.
Upvotes: 3
Views: 3574
Reputation: 11044
Override the public property $name
/**
* The displayable name of the action.
*
* @var string
*/
public $name;
So in your example
class PrintWithDetail extends Action
{
use InteractsWithQueue, Queueable, SerializesModels;
public $name = "Print met detail";
/**
* Perform the action on the given models.
*
* @param \Laravel\Nova\Fields\ActionFields $fields
* @param \Illuminate\Support\Collection $models
* @return mixed
*/
public function handle(ActionFields $fields, Collection $models)
{
$id = '';
foreach ($models as $model) {
$id = $model->id;
}
return Action::openInNewTab(route("print.work.order", [$id, 'type' => 'detail']));
}
}
You can see all what you can change in the class the action extends in nova/src/Actions/Action.php
If you need the name localized in other languages, you may override the method name
return a string from the Laravel __()
helper method
/**
* Get the displayable name of the action.
*
* @return string
*/
public function name()
{
return __('Print with details');
}
Upvotes: 10