diff --git a/resources/views/day-of-week.blade.php b/resources/views/day-of-week.blade.php index f141b4e..fd5b54b 100644 --- a/resources/views/day-of-week.blade.php +++ b/resources/views/day-of-week.blade.php @@ -1,8 +1,8 @@
-

- {{ $day->format('l') }} +

+ {{ $day->locale(app()->getLocale())->isoFormat('dddd') }}

diff --git a/resources/views/day.blade.php b/resources/views/day.blade.php index 325e978..0218bce 100644 --- a/resources/views/day.blade.php +++ b/resources/views/day.blade.php @@ -25,7 +25,7 @@ class="w-full h-full p-2 {{ $dayInMonth ? $isToday ? 'bg-yellow-100' : ' bg-whit

@if($events->isNotEmpty()) - {{ $events->count() }} {{ Str::plural('event', $events->count()) }} + {{ $events->count() }} {{ __(Str::plural('event', $events->count())) }} @endif

diff --git a/resources/views/event.blade.php b/resources/views/event.blade.php index 6e5a347..8bdb322 100644 --- a/resources/views/event.blade.php +++ b/resources/views/event.blade.php @@ -8,6 +8,6 @@ class="bg-white rounded-lg border py-2 px-3 shadow-md cursor-pointer"> {{ $event['title'] }}

- {{ $event['description'] ?? 'No description' }} + {{ $event['description'] ?? __('No description') }}

diff --git a/tests/Support/LivewireCalendarTestComponent.php b/tests/Support/LivewireCalendarTestComponent.php index 5a362a5..7d2107a 100644 --- a/tests/Support/LivewireCalendarTestComponent.php +++ b/tests/Support/LivewireCalendarTestComponent.php @@ -9,6 +9,25 @@ class LivewireCalendarTestComponent extends LivewireCalendar { public function events(): Collection { - return collect(); + return collect([ + [ + 'id' => 1, + 'title' => 'Breakfast', + 'description' => 'Pancakes! 🥞', + 'date' => now()->startOfMonth(), + ], + [ + 'id' => 2, + 'title' => 'Meeting with Pamela', + 'description' => 'Work stuff', + 'date' => now()->startOfMonth(), + ], + [ + 'id' => 2, + 'title' => 'Meeting with Frank', + 'description' => null, + 'date' => now()->startOfMonth()->addDay(), + ], + ]); } } diff --git a/tests/ViewLocalization.php b/tests/ViewLocalization.php new file mode 100644 index 0000000..08eaea5 --- /dev/null +++ b/tests/ViewLocalization.php @@ -0,0 +1,53 @@ +setLocale('en'); + Livewire::test(LivewireCalendarTestComponent::class) + ->assertSeeText('Monday') + ->assertDontSeeText('понеділок'); + app()->setLocale('uk'); + Livewire::test(LivewireCalendarTestComponent::class) + ->assertDontSeeText('Monday') + ->assertSeeText('понеділок'); + } + + public function testEventsLocalization(): void + { + /** @var \Illuminate\Translation\Translator $translator */ + $translator = app('translator'); + $translator->addLines(['*.event' => 'подія', '*.events' => 'події'], 'uk'); + + app()->setLocale('en'); + Livewire::test(LivewireCalendarTestComponent::class) + ->assertSeeText('1 event') + ->assertSeeText('2 events'); + + app()->setLocale('uk'); + Livewire::test(LivewireCalendarTestComponent::class) + ->assertSeeText('1 подія') + ->assertSeeText('2 події'); + } + + public function testNoDescriptionLocalization(): void + { + /** @var \Illuminate\Translation\Translator $translator */ + $translator = app('translator'); + $translator->addLines(['*.No description' => 'без опису'], 'uk'); + + app()->setLocale('en'); + Livewire::test(LivewireCalendarTestComponent::class) + ->assertSeeText('No description'); + + app()->setLocale('uk'); + Livewire::test(LivewireCalendarTestComponent::class) + ->assertSeeText('без опису'); + } +}