Skip to content

Commit f60ef12

Browse files
committed
Set and restore locale for calendar generation
1 parent 449cf5c commit f60ef12

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Tags/Events.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public function between(): EntryCollection|array
3434

3535
public function calendar(): Collection
3636
{
37+
$currentLocale = CarbonImmutable::getLocale();
38+
CarbonImmutable::setLocale(Site::current()->locale());
39+
3740
$month = $this->params->get('month', now()->englishMonth);
3841
$year = $this->params->get('year', now()->year);
3942

@@ -46,7 +49,11 @@ public function calendar(): Collection
4649
->groupBy(fn (Entry $occurrence) => $occurrence->start->toDateString())
4750
->map(fn (EntryCollection $occurrences, string $date) => $this->day(date: $date, occurrences: $occurrences));
4851

49-
return $this->output($this->makeEmptyDates(from: $from, to: $to)->merge($occurrences)->values());
52+
$days = $this->output($this->makeEmptyDates(from: $from, to: $to)->merge($occurrences)->values());
53+
54+
CarbonImmutable::setLocale($currentLocale);
55+
56+
return $days;
5057
}
5158

5259
public function daysOfWeek(): Collection

0 commit comments

Comments
 (0)