Skip to content

Commit

Permalink
Add translations
Browse files Browse the repository at this point in the history
  • Loading branch information
insoutt committed Apr 9, 2024
1 parent 79b35f0 commit ec1ae38
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
13 changes: 13 additions & 0 deletions lang/ecuador/es/holidays.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"New Year's Day": "Año Nuevo",
"Holy Friday": "Viernes Santo",
"Carnival Monday": "Lunes de Carnaval",
"Carnival Tuesday": "Martes de Carnaval",
"Labor Day": "Día del Trabajo",
"Battle of Pichincha": "Batalla de Pichincha",
"Independence Day": "Primer Grito de la Independencia",
"Independence Of Guayaquil": "Independencia de Guayaquil",
"All Souls' Day": "Día de Los Difuntos",
"Independence Of Cuenca": "Independencia de Cuenca",
"Christmas": "Navidad"
}
32 changes: 20 additions & 12 deletions src/Countries/Ecuador.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@

use Carbon\CarbonImmutable;
use Spatie\Holidays\Concerns\Observable;
use Spatie\Holidays\Concerns\Translatable;
use Spatie\Holidays\Contracts\HasTranslations;

class Ecuador extends Country
class Ecuador extends Country implements HasTranslations
{
use Observable;
use Translatable;

public function countryCode(): string
{
return 'ec';
}

public function defaultLocale(): string
{
return 'en';
}

protected function allHolidays(int $year): array
{
return array_merge([
'Año Nuevo' => '01-01',
'New Year\'s Day' => '01-01',
], $this->variableHolidays($year));
}

Expand Down Expand Up @@ -58,16 +66,16 @@ protected function variableHolidays(int $year): array
$carnivalTuesday = $ashWednesday->subDay();

return [
'Viernes Santo' => $easter->subDays(2),
'Lunes de Carnaval' => $carnivalMonday,
'Martes de Carnaval' => $carnivalTuesday,
'Día del Trabajo' => $this->nearestDay($year, 5, 1),
'Batalla de Pichincha' => $this->nearestDay($year, 5, 24),
'Primer Grito de la Independencia' => $this->nearestDay($year, 8, 10),
'Independencia de Guayaquil' => $this->nearestDay($year, 10, 9),
'Día de Los Difuntos' => $this->nearestDay($year, 11, 2),
'Independencia de Cuenca' => $this->nearestDay($year, 11, 3),
'Navidad' => $this->getChristmasHoliday($year),
'Holy Friday' => $easter->subDays(2),
'Carnival Monday' => $carnivalMonday,
'Carnival Tuesday' => $carnivalTuesday,
'Labor Day' => $this->nearestDay($year, 5, 1),
'Battle of Pichincha' => $this->nearestDay($year, 5, 24),
'Independence Day' => $this->nearestDay($year, 8, 10),
'Independence Of Guayaquil' => $this->nearestDay($year, 10, 9),
'All Souls\' Day' => $this->nearestDay($year, 11, 2),
'Independence Of Cuenca' => $this->nearestDay($year, 11, 3),
'Christmas' => $this->getChristmasHoliday($year),
];
}
}
2 changes: 1 addition & 1 deletion tests/Countries/EcuadorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
it('can calculate ecuador holidays', function () {
CarbonImmutable::setTestNow('2024-01-01');

$holidays = Holidays::for(country: 'ec')->get();
$holidays = Holidays::for(country: 'ec', locale: 'es')->get();

expect($holidays)
->toBeArray()
Expand Down

0 comments on commit ec1ae38

Please sign in to comment.