Skip to content

Commit

Permalink
Load scoped form localizations from vendor lang (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni authored May 24, 2024
1 parent 02692a4 commit daabff1
Showing 1 changed file with 27 additions and 9 deletions.
36 changes: 27 additions & 9 deletions src/Livewire/Concerns/WithMessages.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,40 @@ trait WithMessages
{
public function successMessage(): string
{
return Lang::has("livewire-forms.{$this->handle}.success_message")
? __("livewire-forms.{$this->handle}.success_message")
: __('livewire-forms::messages.success_message');
if (Lang::has("livewire-forms.{$this->handle}.success_message")) {
return __("livewire-forms.{$this->handle}.success_message");
}

if (Lang::has("livewire-forms::messages.{$this->handle}.success_message")) {
return __("livewire-forms::messages.{$this->handle}.success_message");
}

return __('livewire-forms::messages.success_message');
}

public function errorMessage(): string
{
return Lang::has("livewire-forms.{$this->handle}.error_message")
? trans_choice("livewire-forms.{$this->handle}.error_message", $this->getErrorBag()->count())
: trans_choice('livewire-forms::messages.error_message', $this->getErrorBag()->count());
if (Lang::has("livewire-forms.{$this->handle}.error_message")) {
return trans_choice("livewire-forms.{$this->handle}.error_message", $this->getErrorBag()->count());
}

if (Lang::has("livewire-forms::messages.{$this->handle}.error_message")) {
return trans_choice("livewire-forms::messages.{$this->handle}.error_message", $this->getErrorBag()->count());
}

return trans_choice('livewire-forms::messages.error_message', $this->getErrorBag()->count());
}

public function submitButtonLabel(): string
{
return Lang::has("livewire-forms.{$this->handle}.submit_button_label")
? __("livewire-forms.{$this->handle}.submit_button_label")
: __('livewire-forms::messages.submit_button_label');
if (Lang::has("livewire-forms.{$this->handle}.submit_button_label")) {
return __("livewire-forms.{$this->handle}.submit_button_label");
}

if (Lang::has("livewire-forms::messages.{$this->handle}.submit_button_label")) {
return __("livewire-forms::messages.{$this->handle}.submit_button_label");
}

return __('livewire-forms::messages.submit_button_label');
}
}

0 comments on commit daabff1

Please sign in to comment.