diff --git a/lang/bahrain/en/holidays.json b/lang/bahrain/en/holidays.json deleted file mode 100644 index a5be25ff9..000000000 --- a/lang/bahrain/en/holidays.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "New Year\\'s Day": "New Year\\'s Day", - "Labour Day": "Labour Day", - "Eid al-Fitr": "Eid al-Fitr", - "Eid al-Fitr Day 2": "Eid al-Fitr", - "Eid al-Fitr Day 3": "Eid al-Fitr", - "Eid al-Adha": "Eid al-Adha", - "Eid al-Adha Day 2": "Eid al-Adha", - "Eid al-Adha Day 3": "Eid al-Adha", - "Islamic New Year": "Islamic New Year", - "Birthday of the Prophet Muhammad": "Birthday of the Prophet Muhammad", - "Arafat Day": "Arafat Day", - "National Day": "National Day", - "National Day 2": "National Day", - "Arafat Day 2": "Arafat Day", -} diff --git a/lang/bangladesh/en/holidays.json b/lang/bangladesh/en/holidays.json deleted file mode 100644 index 456af3986..000000000 --- a/lang/bangladesh/en/holidays.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "International Mother Language Day": "International Mother Language Day", - "Birthday of Sheikh Mujibur Rahman": "Birthday of Sheikh Mujibur Rahman", - "Independence Day": "Independence Day", - "Bengali New Year": "Bengali New Year", - "May Day": "May Day", - "National Mourning Day": "National Mourning Day", - "Victory Day": "Victory Day", - "Christmas Day": "Christmas Day" -} diff --git a/lang/egypt/en/holidays.json b/lang/egypt/en/holidays.json deleted file mode 100644 index a503639ee..000000000 --- a/lang/egypt/en/holidays.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "New Year\\'s Day": "New Year\\'s Day", - "Coptic Christmas Day": "Coptic Christmas Day", - "Revolution Day 2011": "Revolution Day 2011", - "March Equinox": "March Equinox", - "Sinai Liberation Day": "Sinai Liberation Day", - "Labour Day": "Labour Day", - "Coptic Good Friday": "Coptic Good Friday", - "Coptic Holy Saturday": "Coptic Holy Saturday", - "Coptic Easter Sunday": "Coptic Easter Sunday", - "Spring Festival": "Spring Festival", - "June Solstice": "June Solstice", - "June 30 Revolution Day": "June 30 Revolution Day", - "Day off for June 30 Revolution Day": "Day off for June 30 Revolution Day", - "Revolution Day": "Revolution Day", - "Day off for Revolution Day": "Day off for Revolution Day", - "Flooding of the Nile": "Flooding of the Nile", - "Nayrouz": "Nayrouz", - "September Equinox": "September Equinox", - "Armed Forces Day": "Armed Forces Day", - "Day off for Armed Forces Day": "Day off for Armed Forces", - "December Solstice": "December Solstice", - "Eid al-Fitr": "Eid al-Fitr", - "Eid al-Fitr Day 2": "Eid al-Fitr", - "Eid al-Fitr Day 3": "Eid al-Fitr", - "Eid al-Adha": "Eid al-Adha", - "Eid al-Adha Day 2": "Eid al-Adha", - "Eid al-Adha Day 3": "Eid al-Adha", - "Eid al-Adha Day 4": "Eid al-Adha", - "Islamic New Year": "Islamic New Year (Muharram)", - "Birthday of the Prophet Muhammad": "Birthday of the Prophet Muhammad", - "Arafat Day": "Arafat Day", -} diff --git a/lang/iran/fa/holidays.json b/lang/iran/fa/holidays.json deleted file mode 100644 index a8f7a256b..000000000 --- a/lang/iran/fa/holidays.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "پیروزی انقلاب اسلامی پنجاه و هفت": "پیروزی انقلاب اسلامی پنجاه و هفت", - "روز ملی شدن صنعت نفت": "روز ملی شدن صنعت نفت", - "نخستین روز نوروز": "نخستین روز نوروز", - "دومین روز نوروز": "دومین روز نوروز", - "سومین روز نوروز": "سومین روز نوروز", - "چهارمین روز نوروز": "چهارمین روز نوروز", - "روز جمهوری اسلامی": "روز جمهوری اسلامی", - "سیزده بدر": "سیزده بدر", - "رحلت روح\u200Cالله خمینی": "رحلت روح\u200Cالله خمینی", - "قیام ۱۵ خرداد": "قیام ۱۵ خرداد" -} \ No newline at end of file diff --git a/lang/montenegro/sr/holidays.json b/lang/montenegro/sr/holidays.json deleted file mode 100644 index e09ad680a..000000000 --- a/lang/montenegro/sr/holidays.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "Nova godina - prvi dan": "Nova godina - prvi dan", - "Nova godina - drugi dan": "Nova godina - drugi dan", - "Badnji dan": "Badnji dan", - "Božić - prvi dan": "Božić - prvi dan", - "Božić - drugi dan": "Božić - drugi dan", - "Praznik rada - prvi dan": "Praznik rada - prvi dan", - "Praznik rada - drugi dan": "Praznik rada - drugi dan", - "Veliki petak": "Veliki petak", - "Vaskrs": "Vaskrs", - "Vaskršnji ponedjeljak": "Vaskršnji ponedeljak", - "Dan nezavisnosti - prvi dan": "Dan nezavisnosti - prvi dan", - "Dan nezavisnosti - drugi dan": "Dan nezavisnosti - drugi dan", - "Dan državnosti - prvi dan": "Dan državnosti - prvi dan", - "Dan državnosti - drugi dan": "Dan državnosti - drugi dan", - "Njegošev dan - prvi dan": "Njegošev dan - prvi dan", - "Njegošev dan - drugi dan": "Njegošev dan - drugi dan" -} \ No newline at end of file diff --git a/lang/switzerland/de/holidays.json b/lang/switzerland/de/holidays.json deleted file mode 100644 index f59358468..000000000 --- a/lang/switzerland/de/holidays.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "Neujahr": "Neujahr", - "Berchtoldstag": "Berchtoldstag", - "Heilige Drei Könige": "Heilige Drei Könige", - "Josefstag": "Josefstag", - "Karfreitag": "Karfreitag", - "Ostermontag": "Ostermontag", - "Tag der Arbeit": "Tag der Arbeit", - "Auffahrt": "Auffahrt", - "Pfingstmontag": "Pfingstmontag", - "Fronleichnam": "Fronleichnam", - "Bundesfeier": "Bundesfeier", - "Maria Himmelfahrt": "Maria Himmelfahrt", - "Buss- und Bettag" : "Buss- und Bettag", - "Allerheiligen": "Allerheiligen", - "Maria Empfängnis": "Maria Empfängnis", - "Weihnachtstag": "Weihnachtstag", - "Stephanstag": "Stephanstag" -} diff --git a/src/Concerns/Translatable.php b/src/Concerns/Translatable.php index 237c8905a..4b33cbb64 100644 --- a/src/Concerns/Translatable.php +++ b/src/Concerns/Translatable.php @@ -6,10 +6,15 @@ trait Translatable { - protected function translate(string $country, string $name, ?string $locale = null): string + public function translate(string $country, string $name, ?string $locale = null): string { if ($locale === null) { return $name; + + } + + if ($locale === $this->defaultLocale()) { + return $name; } $countryName = strtolower($country); diff --git a/src/Contracts/HasTranslations.php b/src/Contracts/HasTranslations.php new file mode 100644 index 000000000..45939535b --- /dev/null +++ b/src/Contracts/HasTranslations.php @@ -0,0 +1,10 @@ + */ protected function variableHolidays(int $year): array { - // does not change according to the standard return []; } } diff --git a/src/Countries/Bahrain.php b/src/Countries/Bahrain.php index 1c7cee12d..9d9b4d6ba 100644 --- a/src/Countries/Bahrain.php +++ b/src/Countries/Bahrain.php @@ -4,10 +4,14 @@ use Carbon\CarbonImmutable; use Carbon\CarbonInterface; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; use Spatie\Holidays\Exceptions\InvalidYear; -class Bahrain extends Country +class Bahrain extends Country implements HasTranslations { + use Translatable; + protected const EID_AL_FITR_HOLIDAYS = [ 2020 => '05-24', 2021 => '05-13', @@ -139,6 +143,11 @@ public function countryCode(): string return 'bh'; } + public function defaultLocale(): string + { + return 'en'; + } + protected function allHolidays(int $year): array { $variableHolidays = $this->variableHolidays($year); diff --git a/src/Countries/Bangladesh.php b/src/Countries/Bangladesh.php index b269f53dd..a11c99074 100644 --- a/src/Countries/Bangladesh.php +++ b/src/Countries/Bangladesh.php @@ -3,14 +3,23 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Bangladesh extends Country +class Bangladesh extends Country implements HasTranslations { + use Translatable; + public function countryCode(): string { return 'bd'; } + public function defaultLocale(): string + { + return 'en'; + } + protected function allHolidays(int $year): array { return array_merge([ diff --git a/src/Countries/Belarus.php b/src/Countries/Belarus.php index f065d714e..18eca92b7 100644 --- a/src/Countries/Belarus.php +++ b/src/Countries/Belarus.php @@ -3,14 +3,23 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Belarus extends Country +class Belarus extends Country implements HasTranslations { + use Translatable; + public function countryCode(): string { return 'by'; } + public function defaultLocale(): string + { + return 'be'; + } + protected function allHolidays(int $year): array { return array_merge([ diff --git a/src/Countries/Belgium.php b/src/Countries/Belgium.php index 8710daf74..3c9b423b1 100644 --- a/src/Countries/Belgium.php +++ b/src/Countries/Belgium.php @@ -3,14 +3,23 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Belgium extends Country +class Belgium extends Country implements HasTranslations { + use Translatable; + public function countryCode(): string { return 'be'; } + public function defaultLocale(): string + { + return 'nl'; + } + protected function allHolidays(int $year): array { return array_merge([ diff --git a/src/Countries/Country.php b/src/Countries/Country.php index 8c0322e21..c0a668606 100644 --- a/src/Countries/Country.php +++ b/src/Countries/Country.php @@ -3,14 +3,12 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; -use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; use Spatie\Holidays\Exceptions\InvalidCountry; use Spatie\Holidays\Exceptions\InvalidYear; abstract class Country { - use Translatable; - abstract public function countryCode(): string; /** @return array */ @@ -33,7 +31,9 @@ public function get(int $year, ?string $locale = null): array } } - $name = $this->translate(basename(str_replace('\\', '/', static::class)), $name, $locale); + if ($this instanceof HasTranslations) { + $name = $this->translate(basename(str_replace('\\', '/', static::class)), $name, $locale); + } $translatedHolidays[$name] = $date; } diff --git a/src/Countries/Egypt.php b/src/Countries/Egypt.php index 464759c26..d6f8af4ef 100644 --- a/src/Countries/Egypt.php +++ b/src/Countries/Egypt.php @@ -4,10 +4,14 @@ use Carbon\CarbonImmutable; use Carbon\CarbonInterface; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; use Spatie\Holidays\Exceptions\InvalidYear; -class Egypt extends Country +class Egypt extends Country implements HasTranslations { + use Translatable; + protected const EID_AL_FITR_HOLIDAYS = [ 2005 => '11-04', 2006 => '10-24', @@ -229,6 +233,11 @@ public function countryCode(): string return 'eg'; } + public function defaultLocale(): string + { + return 'en'; + } + protected function allHolidays(int $year): array { $fixedHolidays = $this->fixedHolidays($year); diff --git a/src/Countries/Finland.php b/src/Countries/Finland.php index bcb2e72cd..c9d6d6014 100644 --- a/src/Countries/Finland.php +++ b/src/Countries/Finland.php @@ -4,14 +4,23 @@ use Carbon\CarbonImmutable; use Carbon\CarbonInterface; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Finland extends Country +class Finland extends Country implements HasTranslations { + use Translatable; + public function countryCode(): string { return 'fi'; } + public function defaultLocale(): string + { + return 'fi'; + } + protected function allHolidays(int $year): array { return array_merge( diff --git a/src/Countries/Germany.php b/src/Countries/Germany.php index fda0dc46e..04fdda152 100644 --- a/src/Countries/Germany.php +++ b/src/Countries/Germany.php @@ -3,9 +3,13 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Germany extends Country +class Germany extends Country implements HasTranslations { + use Translatable; + protected function __construct( protected ?string $region = null, ) { @@ -16,6 +20,11 @@ public function countryCode(): string return 'de'; } + public function defaultLocale(): string + { + return 'de'; + } + protected function allHolidays(int $year): array { return array_merge([ diff --git a/src/Countries/Iran.php b/src/Countries/Iran.php index a70be6c58..d118bf913 100644 --- a/src/Countries/Iran.php +++ b/src/Countries/Iran.php @@ -2,13 +2,23 @@ namespace Spatie\Holidays\Countries; -class Iran extends Country +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; + +class Iran extends Country implements HasTranslations { + use Translatable; + public function countryCode(): string { return 'ir'; } + public function defaultLocale(): string + { + return 'fa'; + } + protected function allHolidays(int $year): array { return [ diff --git a/src/Countries/Montenegro.php b/src/Countries/Montenegro.php index 9ff1de06e..a8d41397c 100644 --- a/src/Countries/Montenegro.php +++ b/src/Countries/Montenegro.php @@ -3,14 +3,23 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Montenegro extends Country +class Montenegro extends Country implements HasTranslations { + use Translatable; + public function countryCode(): string { return 'me'; } + public function defaultLocale(): string + { + return 'sr'; + } + public function allHolidays(int $year): array { // Montenegro has two days off for most holidays diff --git a/src/Countries/Switzerland.php b/src/Countries/Switzerland.php index d4d710689..d9305fbf0 100644 --- a/src/Countries/Switzerland.php +++ b/src/Countries/Switzerland.php @@ -3,10 +3,14 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; use Spatie\Holidays\Exceptions\InvalidRegion; -class Switzerland extends Country +class Switzerland extends Country implements HasTranslations { + use Translatable; + private const REGIONS = [ 'ch-ag', 'ch-ar', @@ -82,6 +86,11 @@ public function countryCode(): string return 'ch'; } + public function defaultLocale(): string + { + return 'de'; + } + /** * @return array */ diff --git a/src/Countries/Syria.php b/src/Countries/Syria.php index 86ecd5d38..51d9e5f68 100644 --- a/src/Countries/Syria.php +++ b/src/Countries/Syria.php @@ -3,14 +3,23 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Syria extends Country +class Syria extends Country implements HasTranslations { + use Translatable; + public function countryCode(): string { return 'sy'; } + public function defaultLocale(): string + { + return 'en'; + } + protected function allHolidays(int $year): array { return array_merge([ diff --git a/src/Countries/Uzbekistan.php b/src/Countries/Uzbekistan.php index ffb371916..ceb3cade3 100644 --- a/src/Countries/Uzbekistan.php +++ b/src/Countries/Uzbekistan.php @@ -3,9 +3,13 @@ namespace Spatie\Holidays\Countries; use Carbon\CarbonImmutable; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Uzbekistan extends Country +class Uzbekistan extends Country implements HasTranslations { + use Translatable; + /** * Islamic holidays (Ramadan & Sacrifice) are obtained constantly from 1991 to 2037 (https://www.timeanddate.com/holidays/uzbekistan/) */ @@ -123,6 +127,11 @@ public function countryCode(): string return 'uz'; } + public function defaultLocale(): string + { + return 'uz'; + } + /** @return array */ protected function allHolidays(int $year): array { diff --git a/src/Countries/Vietnam.php b/src/Countries/Vietnam.php index 7d6504047..a57ae68a7 100644 --- a/src/Countries/Vietnam.php +++ b/src/Countries/Vietnam.php @@ -5,16 +5,24 @@ use Carbon\CarbonImmutable; use Carbon\CarbonInterface; use Spatie\Holidays\Calendars\ChineseCalendar; +use Spatie\Holidays\Concerns\Translatable; +use Spatie\Holidays\Contracts\HasTranslations; -class Vietnam extends Country +class Vietnam extends Country implements HasTranslations { use ChineseCalendar; + use Translatable; public function countryCode(): string { return 'vn'; } + public function defaultLocale(): string + { + return 'vi'; + } + protected function allHolidays(int $year): array { return array_merge([