feat: add Somalia (SO) country support with Arabic translations#3393
feat: add Somalia (SO) country support with Arabic translations#3393Prabhu-bit wants to merge 2 commits into
Conversation
Summary by CodeRabbit
WalkthroughThis PR adds Arabic localization to Somalia: declares Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Adds Arabic (ar) localization support for Somalia (SO) holidays, with accompanying tests.
Changes:
- Add Arabic locale resources for Somalia under
holidays/locale/ar/LC_MESSAGES/. - Register Arabic as a supported language for the Somalia holiday entity.
- Add Arabic localization assertions to Somalia’s country test suite.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/countries/test_somalia.py | Adds a new test validating Arabic holiday name localization. |
| holidays/version.py | Changes how __version__ is defined. |
| holidays/locale/ar/LC_MESSAGES/SO.po | Introduces Arabic translations for Somalia’s holiday strings. |
| holidays/locale/ar/LC_MESSAGES/SO.mo | Adds a compiled gettext catalog for Somalia Arabic. |
| holidays/countries/somalia.py | Declares Arabic as a supported language; adjusts docstring formatting. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Website: https://github.com/vacanza/holidays | ||
| # License: MIT (see LICENSE file) | ||
| # | ||
| # United Arab Emirates holidays. |
There was a problem hiding this comment.
The header comment says "United Arab Emirates holidays." but this file is for Somalia (SO). Please correct the country name in the header to avoid misleading metadata in localization files.
| # United Arab Emirates holidays. | |
| # Somalia holidays. |
| #. New Year's Day. | ||
| msgid "New Year's Day" | ||
| msgstr "رأس السنة الميلادية" | ||
|
|
||
| #. Labour Day. | ||
| msgid "Labour Day" | ||
| msgstr "عيد العمال" | ||
|
|
||
| #. Independence Day. | ||
| msgid "Independence Day" | ||
| msgstr "عيد الاستقلال" | ||
|
|
||
| #. Republic Day. | ||
| msgid "Republic Day" | ||
| msgstr "عيد الجمهورية" | ||
|
|
||
| #. %s (estimated). | ||
| msgid "%s (estimated)" | ||
| msgstr "(المقدرة) %s" No newline at end of file |
There was a problem hiding this comment.
This PO file doesn’t include translations for several holiday names that Somalia defines (e.g., "Islamic New Year", "Ashura", "Prophet's Birthday", "Isra' and Mi'raj", "Eid al-Fitr", "Eid al-Adha"). As-is, Arabic localization will still show those holidays in English, which contradicts the PR description claiming full Arabic translations for all Somalia public holidays.
| """ | ||
|
|
||
| country = "SO" | ||
| supported_languages = ("ar",) |
There was a problem hiding this comment.
supported_languages only lists "ar". In this codebase, country entities that support Arabic typically include "en_US" as well (e.g., holidays/countries/bahrain.py sets supported_languages = ("ar", "en_US")). Omitting "en_US" can cause ICalExporter(show_language=True) to treat language="en_US" as unsupported and drop/raise unexpectedly. Consider including "en_US" alongside "ar".
| supported_languages = ("ar",) | |
| supported_languages = ("ar", "en_US") |
| Whether to add "estimated" label to Islamic holidays name | ||
| if holiday date is estimated. |
There was a problem hiding this comment.
Docstring indentation under Args: is off: the description lines for islamic_show_estimated are not indented under the parameter name. This is inconsistent with other country classes and makes the rendered docs harder to read; indent the description block under islamic_show_estimated:.
| Whether to add "estimated" label to Islamic holidays name | |
| if holiday date is estimated. | |
| Whether to add "estimated" label to Islamic holidays name | |
| if holiday date is estimated. |
|
|
||
| # Remove the extra space at the end of each Arabic string |
There was a problem hiding this comment.
There is trailing whitespace on the blank line after ar_holidays = Somalia(language="ar") (will trip Ruff/flake8 W291). Also, the comment about removing trailing spaces is misleading since the test doesn’t strip anything. Please remove the trailing whitespace and update/remove the comment to reflect what the test is actually asserting.
| # Remove the extra space at the end of each Arabic string | |
| # Ensure the Arabic holiday names match the expected strings exactly |
| ("2018-11-20", "Prophet's Birthday (estimated)"), | ||
| ) | ||
|
|
||
| def test_l10n_arabic(self): |
There was a problem hiding this comment.
Test naming is inconsistent with the existing l10n tests in this repo, which use the locale code in the method name (e.g., test_l10n_ar, test_l10n_en_us). Consider renaming test_l10n_arabic to test_l10n_ar to match the established pattern in tests/countries/*.
| def test_l10n_arabic(self): | |
| def test_l10n_ar(self): |
| from importlib.metadata import version | ||
|
|
||
| __version__ = version("holidays") | ||
| __version__ = "0.45" No newline at end of file |
There was a problem hiding this comment.
__version__ is hard-coded to "0.45", but the repo’s packaging version is sourced from the VERSION file (currently 0.94). This will make holidays.__version__ disagree with distribution metadata and can break tests/test_package.py (which asserts metadata("holidays")["version"] == holidays.version). Restore a single source of truth for the version (e.g., use importlib.metadata.version("holidays") again or read from VERSION).
| __version__ = "0.45" | |
| from importlib.metadata import PackageNotFoundError, version as _get_version | |
| from pathlib import Path | |
| try: | |
| __version__ = _get_version("holidays") | |
| except PackageNotFoundError: | |
| try: | |
| _version_file = Path(__file__).resolve().parent.parent / "VERSION" | |
| __version__ = _version_file.read_text(encoding="utf-8").strip() | |
| except OSError: | |
| # Fallback version if neither package metadata nor VERSION file is available. | |
| __version__ = "0.0.0" |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
holidays/countries/somalia.py (1)
44-73: 🛠️ Refactor suggestion | 🟠 MajorHoliday names should use
tr()wrapper for localization support.With
supported_languagesdeclared, holiday names should be wrapped withtr()to enable proper localization. This is the established pattern for l10n-enabled country implementations.Proposed fix
+from holidays.calendars.gregorian import JUN, JUL +from holidays.groups import InternationalHolidays, IslamicHolidays +from holidays.holiday_base import HolidayBase +from holidays.l10n import tr ... def _populate_public_holidays(self): # New Year's Day. - self._add_new_years_day("New Year's Day") + self._add_new_years_day(tr("New Year's Day")) # Labor Day. - self._add_labor_day("Labour Day") + self._add_labor_day(tr("Labour Day")) # Independence Day. - self._add_holiday_jun_26("Independence Day") + self._add_holiday_jun_26(tr("Independence Day")) # Republic Day. - self._add_holiday_jul_1("Republic Day") + self._add_holiday_jul_1(tr("Republic Day")) # Islamic New Year. - self._add_islamic_new_year_day("Islamic New Year") + self._add_islamic_new_year_day(tr("Islamic New Year")) # Ashura. - self._add_ashura_day("Ashura") + self._add_ashura_day(tr("Ashura")) # Prophet's Birthday. - self._add_mawlid_day("Prophet's Birthday") + self._add_mawlid_day(tr("Prophet's Birthday")) # Isra' and Mi'raj. - self._add_isra_and_miraj_day("Isra' and Mi'raj") + self._add_isra_and_miraj_day(tr("Isra' and Mi'raj")) # Eid al-Fitr. - self._add_eid_al_fitr_day("Eid al-Fitr") + self._add_eid_al_fitr_day(tr("Eid al-Fitr")) # Eid al-Adha. - self._add_eid_al_adha_day("Eid al-Adha") + self._add_eid_al_adha_day(tr("Eid al-Adha"))Based on learnings: "In the holidays library, countries with localization support DO use tr() wrappers around holiday names when calling add* methods."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@holidays/countries/somalia.py` around lines 44 - 73, The holiday name strings in _populate_public_holidays should be wrapped with tr() for localization; update each call to methods like _add_new_years_day, _add_labor_day, _add_holiday_jun_26, _add_holiday_jul_1, _add_islamic_new_year_day, _add_ashura_day, _add_mawlid_day, _add_isra_and_miraj_day, _add_eid_al_fitr_day, and _add_eid_al_adha_day to pass tr("...") instead of raw literals (e.g., tr("New Year's Day")), ensuring the module’s supported_languages localization is used consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@holidays/countries/somalia.py`:
- Around line 25-28: Add a default_language attribute set to "ar" and update
supported_languages to include "en_US" if you want consistency with other
Arabic-speaking countries; change supported_languages from ("ar",) to ("ar",
"en_US") (or keep only "ar" if you intentionally exclude English). Also wrap the
estimated_label in the translation helper by replacing the plain string with a
call to tr("%s (estimated)") so localization uses the .po files; adjust the
symbols country, supported_languages, default_language, and estimated_label
accordingly.
In `@holidays/locale/ar/LC_MESSAGES/SO.po`:
- Line 13: Replace the incorrect header comment "# United Arab Emirates
holidays." in the SO.po locale file with a correct description for Somalia
(e.g., "Somalia holidays ar localization.") so the header accurately reflects
the file's purpose; locate the offending comment line that currently reads "#
United Arab Emirates holidays." and update its text accordingly.
- Around line 46-48: The Arabic translation in the SO.po file uses the
placeholder after the text, which is inconsistent with the project pattern;
update the msgstr for the msgid "%s (estimated)" by moving the "%s" to the start
so it matches other Arabic locale files (see ET.po) — change the msgstr
"(المقدرة) %s" to "%s (المقدرة)" for the entry corresponding to msgid "%s
(estimated)".
In `@holidays/version.py`:
- Line 13: The __version__ constant in holidays/version.py is hardcoded as
"0.45" and must match the canonical version; update the __version__ variable in
holidays/version.py from "0.45" to "0.94" so it matches the VERSION file and
satisfies tests such as tests/test_package.py::TestPackage::test_metadata that
compare holidays.__version__ against the installed package version.
In `@tests/countries/test_somalia.py`:
- Around line 137-145: Remove the misleading inline comment in test_l10n_arabic
(there is no trailing space in the Arabic strings) and add an extra assertion
that verifies estimated Islamic holiday translations format correctly:
instantiate Somalia(language="ar") (same as ar_holidays) and assert that an
estimated Islamic holiday returned by ar_holidays.get(...) matches the "%s
(المقدرة)" pattern from the .po file (i.e., the holiday name followed by "
(المقدرة)" in Arabic); use an example date corresponding to an estimated Islamic
holiday from your test data so the assertion exercises the formatting path in
the Somalia.get method.
---
Outside diff comments:
In `@holidays/countries/somalia.py`:
- Around line 44-73: The holiday name strings in _populate_public_holidays
should be wrapped with tr() for localization; update each call to methods like
_add_new_years_day, _add_labor_day, _add_holiday_jun_26, _add_holiday_jul_1,
_add_islamic_new_year_day, _add_ashura_day, _add_mawlid_day,
_add_isra_and_miraj_day, _add_eid_al_fitr_day, and _add_eid_al_adha_day to pass
tr("...") instead of raw literals (e.g., tr("New Year's Day")), ensuring the
module’s supported_languages localization is used consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: d49bafd6-8de2-4d65-bfbb-777c7e3acd17
📒 Files selected for processing (5)
holidays/countries/somalia.pyholidays/locale/ar/LC_MESSAGES/SO.moholidays/locale/ar/LC_MESSAGES/SO.poholidays/version.pytests/countries/test_somalia.py
| country = "SO" | ||
| supported_languages = ("ar",) | ||
| # %s (estimated). | ||
| estimated_label = "%s (estimated)" |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check how other Arabic-supporting countries define language attributes
echo "=== Saudi Arabia ==="
grep -A2 "country = \"SA\"" holidays/countries/saudi_arabia.py
echo -e "\n=== UAE ==="
grep -A2 "country = \"AE\"" holidays/countries/united_arab_emirates.py
echo -e "\n=== Djibouti ==="
grep -A2 "country = \"DJ\"" holidays/countries/djibouti.pyRepository: vacanza/holidays
Length of output: 318
🏁 Script executed:
#!/bin/bash
# Get complete language configuration for Arabic-supporting countries
echo "=== Saudi Arabia (full lines 23-28) ==="
sed -n '23,28p' holidays/countries/saudi_arabia.py
echo -e "\n=== UAE (full lines 23-28) ==="
sed -n '23,28p' holidays/countries/united_arab_emirates.py
echo -e "\n=== Djibouti (full lines 23-28) ==="
sed -n '23,28p' holidays/countries/djibouti.py
echo -e "\n=== Somalia (full lines 23-30) ==="
sed -n '23,30p' holidays/countries/somalia.py
# Check for .po files
echo -e "\n=== Locale files for Somalia ==="
find holidays/locale -name "*SO*" -o -name "*so*" 2>/dev/null | head -20
echo -e "\n=== Locale files for Saudi Arabia ==="
find holidays/locale -name "*SA*" -o -name "*sa*" 2>/dev/null | head -20Repository: vacanza/holidays
Length of output: 1580
🏁 Script executed:
#!/bin/bash
# Find default_language and supported_languages in Saudi Arabia
echo "=== Saudi Arabia language config ==="
grep -n "default_language\|supported_languages" holidays/countries/saudi_arabia.py | head -5
# Check Somalia's .po file for X-Source-Language
echo -e "\n=== Somalia .po file header (first 30 lines) ==="
head -30 holidays/locale/ar/LC_MESSAGES/SO.po
# Check if Somalia uses tr() in holiday definitions
echo -e "\n=== Somalia _populate_public_holidays tr() usage ==="
grep -A100 "def _populate_public_holidays" holidays/countries/somalia.py | grep -E "tr\(|self\._add"Repository: vacanza/holidays
Length of output: 1729
🏁 Script executed:
#!/bin/bash
# Check the full header of Somalia .po file for X-Source-Language
echo "=== Somalia .po file full header ==="
head -50 holidays/locale/ar/LC_MESSAGES/SO.po | grep -E "^\"X-|^#"
# Also check Djibouti's .po for comparison
echo -e "\n=== Djibouti .po file header ==="
head -50 holidays/locale/ar/LC_MESSAGES/DJ.po | grep -E "^\"X-|^#"
# Check if Somalia's estimated_label needs to be using tr()
echo -e "\n=== Djibouti estimated_label pattern ==="
grep "estimated_label" holidays/countries/djibouti.py
# Verify Somalia doesn't have default_language set anywhere
echo -e "\n=== Somalia complete language config check ==="
grep -E "default_language|supported_languages|estimated_label" holidays/countries/somalia.pyRepository: vacanza/holidays
Length of output: 1760
🏁 Script executed:
#!/bin/bash
# Get the full msgstr section for Somalia .po to check for X-Source-Language
echo "=== Somalia .po file complete header msgstr ==="
sed -n '15,40p' holidays/locale/ar/LC_MESSAGES/SO.po
# Compare with a working example like Saudi Arabia
echo -e "\n=== Saudi Arabia .po file header section ==="
sed -n '15,40p' holidays/locale/ar/LC_MESSAGES/SA.po
# Check the actual holiday entries in Somalia to see tr() pattern needed
echo -e "\n=== Somalia first translated entries ==="
sed -n '30,60p' holidays/locale/ar/LC_MESSAGES/SO.poRepository: vacanza/holidays
Length of output: 1700
Add default_language attribute and update localization setup.
Somalia has .po translation files but is missing the required default_language attribute. This should match the primary language of the translations. Compare with Saudi Arabia's pattern:
default_language = "ar"
supported_languages = ("ar", "en_US")
estimated_label = tr("%s (estimated)")Somalia should also use tr() wrapper on estimated_label to enable proper localization, and consider whether to include "en_US" in supported_languages for consistency with other Arabic-speaking countries.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@holidays/countries/somalia.py` around lines 25 - 28, Add a default_language
attribute set to "ar" and update supported_languages to include "en_US" if you
want consistency with other Arabic-speaking countries; change
supported_languages from ("ar",) to ("ar", "en_US") (or keep only "ar" if you
intentionally exclude English). Also wrap the estimated_label in the translation
helper by replacing the plain string with a call to tr("%s (estimated)") so
localization uses the .po files; adjust the symbols country,
supported_languages, default_language, and estimated_label accordingly.
| # Website: https://github.com/vacanza/holidays | ||
| # License: MIT (see LICENSE file) | ||
| # | ||
| # United Arab Emirates holidays. |
There was a problem hiding this comment.
Incorrect header comment - copy-paste error.
The comment says "United Arab Emirates holidays" but this file is for Somalia. Should be "Somalia holidays ar localization."
Proposed fix
-# United Arab Emirates holidays.
+# Somalia holidays ar localization.📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| # United Arab Emirates holidays. | |
| # Somalia holidays ar localization. |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@holidays/locale/ar/LC_MESSAGES/SO.po` at line 13, Replace the incorrect
header comment "# United Arab Emirates holidays." in the SO.po locale file with
a correct description for Somalia (e.g., "Somalia holidays ar localization.") so
the header accurately reflects the file's purpose; locate the offending comment
line that currently reads "# United Arab Emirates holidays." and update its text
accordingly.
| #. %s (estimated). | ||
| msgid "%s (estimated)" | ||
| msgstr "(المقدرة) %s" No newline at end of file |
There was a problem hiding this comment.
Format specifier position inconsistent with codebase pattern.
The %s placeholder should be at the start of the string to match the established pattern in other Arabic locale files. See holidays/locale/ar/LC_MESSAGES/ET.po which uses msgstr "%s (المقدرة)".
Proposed fix
#. %s (estimated).
msgid "%s (estimated)"
-msgstr "(المقدرة) %s"
+msgstr "%s (المقدرة)"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #. %s (estimated). | |
| msgid "%s (estimated)" | |
| msgstr "(المقدرة) %s" | |
| #. %s (estimated). | |
| msgid "%s (estimated)" | |
| msgstr "%s (المقدرة)" |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@holidays/locale/ar/LC_MESSAGES/SO.po` around lines 46 - 48, The Arabic
translation in the SO.po file uses the placeholder after the text, which is
inconsistent with the project pattern; update the msgstr for the msgid "%s
(estimated)" by moving the "%s" to the start so it matches other Arabic locale
files (see ET.po) — change the msgstr "(المقدرة) %s" to "%s (المقدرة)" for the
entry corresponding to msgid "%s (estimated)".
| def test_l10n_arabic(self): | ||
| """Test if Arabic translations from SO.po are correctly loaded.""" | ||
| # Initialize Somalia class with Arabic language | ||
| ar_holidays = Somalia(language="ar") | ||
|
|
||
| # Remove the extra space at the end of each Arabic string | ||
| self.assertEqual(ar_holidays.get("2026-06-26"), "عيد الاستقلال") | ||
| self.assertEqual(ar_holidays.get("2026-07-01"), "عيد الجمهورية") | ||
| self.assertEqual(ar_holidays.get("2026-05-01"), "عيد العمال") |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Test structure looks good; consider expanding coverage.
The unittest-style assertEqual is correct per project conventions - ignore the Ruff PT009 warnings.
A couple of notes:
- The comment on line 142 ("Remove the extra space...") is confusing since there's no extra space in the Arabic strings. Consider removing this misleading comment.
- Consider adding a test for estimated Islamic holidays to verify the
"%s (المقدرة)"translation works correctly, especially given the format specifier concern in the.pofile.
Proposed improvements
def test_l10n_arabic(self):
"""Test if Arabic translations from SO.po are correctly loaded."""
- # Initialize Somalia class with Arabic language
ar_holidays = Somalia(language="ar")
-
- # Remove the extra space at the end of each Arabic string
self.assertEqual(ar_holidays.get("2026-06-26"), "عيد الاستقلال")
self.assertEqual(ar_holidays.get("2026-07-01"), "عيد الجمهورية")
self.assertEqual(ar_holidays.get("2026-05-01"), "عيد العمال")
+
+ # Test estimated label translation for Islamic holidays
+ ar_holidays_with_estimated = Somalia(years=2018, language="ar")
+ # Verify estimated Islamic holiday includes translated label
+ self.assertIn("المقدرة", ar_holidays_with_estimated.get("2018-06-15", ""))🧰 Tools
🪛 Ruff (0.15.6)
[warning] 143-143: Use a regular assert instead of unittest-style assertEqual
Replace assertEqual(...) with assert ...
(PT009)
[warning] 144-144: Use a regular assert instead of unittest-style assertEqual
Replace assertEqual(...) with assert ...
(PT009)
[warning] 145-145: Use a regular assert instead of unittest-style assertEqual
Replace assertEqual(...) with assert ...
(PT009)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/countries/test_somalia.py` around lines 137 - 145, Remove the
misleading inline comment in test_l10n_arabic (there is no trailing space in the
Arabic strings) and add an extra assertion that verifies estimated Islamic
holiday translations format correctly: instantiate Somalia(language="ar") (same
as ar_holidays) and assert that an estimated Islamic holiday returned by
ar_holidays.get(...) matches the "%s (المقدرة)" pattern from the .po file (i.e.,
the holiday name followed by " (المقدرة)" in Arabic); use an example date
corresponding to an estimated Islamic holiday from your test data so the
assertion exercises the formatting path in the Somalia.get method.
|
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (4)
holidays/locale/ar/LC_MESSAGES/SO.po (2)
66-68:⚠️ Potential issue | 🟠 MajorFormat specifier position inconsistent with codebase pattern.
The
%splaceholder should be at the start of the string to match the established pattern in other Arabic locale files likeholidays/locale/ar/LC_MESSAGES/ET.powhich usesmsgstr "%s (المقدرة)".Proposed fix
#. %s (estimated). msgid "%s (estimated)" -msgstr "(المقدرة) %s" +msgstr "%s (المقدرة)"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@holidays/locale/ar/LC_MESSAGES/SO.po` around lines 66 - 68, The Arabic translation for the "%s (estimated)" message has the placeholder at the end which is inconsistent; update the msgstr for the msgid "%s (estimated)" so the "%s" placeholder appears at the start (matching the pattern used in other Arabic locale files), i.e. change the msgstr "(المقدرة) %s" to place "%s" first and keep the Arabic text after it.
13-13:⚠️ Potential issue | 🟡 MinorIncorrect header comment - copy-paste error.
The comment says "United Arab Emirates holidays" but this file is for Somalia. Should be "Somalia holidays ar localization."
Proposed fix
-# United Arab Emirates holidays. +# Somalia holidays ar localization.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@holidays/locale/ar/LC_MESSAGES/SO.po` at line 13, Replace the incorrect header comment "# United Arab Emirates holidays." in the SO.po file with a correct Somalia-specific comment such as "Somalia holidays ar localization." so the header accurately reflects the file's locale and purpose (identify the line containing "# United Arab Emirates holidays." to update).holidays/countries/somalia.py (1)
25-28:⚠️ Potential issue | 🟠 MajorAdd
default_languageattribute and wrapestimated_labelwithtr().Somalia now has
.potranslation files but is missing thedefault_languageattribute andtr()wrapper. Compare with similar Arabic-speaking countries like Saudi Arabia or Djibouti:default_language = "ar" supported_languages = ("ar", "en_US") # %s (estimated). estimated_label = tr("%s (estimated)")Without
default_language, the library won't know which language to use by default. Thetr()wrapper is required for the estimated label to be translated via the.pofile.Proposed fix
country = "SO" +default_language = "ar" supported_languages = ("ar", "en_US") # %s (estimated). -estimated_label = "%s (estimated)" +estimated_label = tr("%s (estimated)")Also add the import at the top:
from gettext import gettext as tr🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@holidays/countries/somalia.py` around lines 25 - 28, Add a default_language attribute and make the estimated label translatable: set default_language = "ar" (to match other Arabic-speaking country modules), wrap estimated_label using tr() so it reads tr("%s (estimated)"), and ensure the module imports gettext as tr (from gettext import gettext as tr) near the top; update the country/Somalia module attributes country, supported_languages, default_language, and estimated_label accordingly.tests/countries/test_somalia.py (1)
137-145: 🧹 Nitpick | 🔵 TrivialMisleading comment and limited test coverage.
The comment on line 142 ("Remove the extra space...") is misleading since there's no extra space removal happening. The test also only covers 3 holidays. Consider:
- Remove the misleading comment
- Test New Year's Day Arabic translation
- Test at least one Islamic holiday Arabic translation
- Test the estimated label format (e.g.,
"عيد الفطر (المقدرة)"for an estimated date)Proposed improvements
def test_l10n_ar(self): - """Test if Arabic translations from SO.po are correctly loaded.""" - # Initialize Somalia class with Arabic language ar_holidays = Somalia(language="ar") - - # Remove the extra space at the end of each Arabic string + self.assertEqual(ar_holidays.get("2026-01-01"), "رأس السنة الميلادية") self.assertEqual(ar_holidays.get("2026-06-26"), "عيد الاستقلال") self.assertEqual(ar_holidays.get("2026-07-01"), "عيد الجمهورية") self.assertEqual(ar_holidays.get("2026-05-01"), "عيد العمال") + # Test Islamic holiday + self.assertEqual(ar_holidays.get("2026-06-06"), "عيد الأضحى")🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/countries/test_somalia.py` around lines 137 - 145, The test_l10n_ar in tests/countries/test_somalia.py contains a misleading comment and insufficient coverage; remove the comment about "Remove the extra space..." and extend the test by asserting Arabic translations via Somalia(language="ar") for New Year's Day (use ar_holidays.get("YYYY-01-01") with the expected Arabic label), at least one Islamic holiday (e.g., check ar_holidays.get for an Eid date), and verify an estimated label format by asserting an estimated holiday returns the form like "عيد الفطر (المقدرة)" using ar_holidays.get on an estimated-date key; update only the test_l10n_ar function and use ar_holidays.get(...) calls to add these assertions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@holidays/locale/ar/LC_MESSAGES/SO.po`:
- Around line 58-65: Add the missing Arabic translation for the "Isra' and
Mi'raj" holiday referenced in somalia.py by adding a msgid/msgstr pair for
"Isra' and Mi'raj" to the PO file (place it after the "Eid al-Adha" entry to
match the locale order); use the Arabic translation "الإسراء والمعراج" for
msgstr so the msgid "Isra' and Mi'raj" has a proper localized string.
---
Duplicate comments:
In `@holidays/countries/somalia.py`:
- Around line 25-28: Add a default_language attribute and make the estimated
label translatable: set default_language = "ar" (to match other Arabic-speaking
country modules), wrap estimated_label using tr() so it reads tr("%s
(estimated)"), and ensure the module imports gettext as tr (from gettext import
gettext as tr) near the top; update the country/Somalia module attributes
country, supported_languages, default_language, and estimated_label accordingly.
In `@holidays/locale/ar/LC_MESSAGES/SO.po`:
- Around line 66-68: The Arabic translation for the "%s (estimated)" message has
the placeholder at the end which is inconsistent; update the msgstr for the
msgid "%s (estimated)" so the "%s" placeholder appears at the start (matching
the pattern used in other Arabic locale files), i.e. change the msgstr
"(المقدرة) %s" to place "%s" first and keep the Arabic text after it.
- Line 13: Replace the incorrect header comment "# United Arab Emirates
holidays." in the SO.po file with a correct Somalia-specific comment such as
"Somalia holidays ar localization." so the header accurately reflects the file's
locale and purpose (identify the line containing "# United Arab Emirates
holidays." to update).
In `@tests/countries/test_somalia.py`:
- Around line 137-145: The test_l10n_ar in tests/countries/test_somalia.py
contains a misleading comment and insufficient coverage; remove the comment
about "Remove the extra space..." and extend the test by asserting Arabic
translations via Somalia(language="ar") for New Year's Day (use
ar_holidays.get("YYYY-01-01") with the expected Arabic label), at least one
Islamic holiday (e.g., check ar_holidays.get for an Eid date), and verify an
estimated label format by asserting an estimated holiday returns the form like
"عيد الفطر (المقدرة)" using ar_holidays.get on an estimated-date key; update
only the test_l10n_ar function and use ar_holidays.get(...) calls to add these
assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 2678a6f4-466a-4e37-bc3c-ffd9fd007765
📒 Files selected for processing (5)
holidays/countries/somalia.pyholidays/locale/ar/LC_MESSAGES/SO.moholidays/locale/ar/LC_MESSAGES/SO.poholidays/version.pytests/countries/test_somalia.py
| #. Eid al-Fitr. | ||
| msgid "Eid al-Fitr" | ||
| msgstr "عيد الفطر" | ||
|
|
||
| #. Eid al-Adha. | ||
| msgid "Eid al-Adha" | ||
| msgstr "عيد الأضحى" | ||
|
|
There was a problem hiding this comment.
Missing translation for "Isra' and Mi'raj".
The Somalia implementation in somalia.py includes Isra' and Mi'raj holiday (Line 67), but this translation is missing from the PO file. Add the Arabic translation for completeness.
Proposed fix - add after Eid al-Adha entry
#. Eid al-Adha.
msgid "Eid al-Adha"
msgstr "عيد الأضحى"
+
+#. Isra' and Mi'raj.
+msgid "Isra' and Mi'raj"
+msgstr "الإسراء والمعراج"
#. %s (estimated).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@holidays/locale/ar/LC_MESSAGES/SO.po` around lines 58 - 65, Add the missing
Arabic translation for the "Isra' and Mi'raj" holiday referenced in somalia.py
by adding a msgid/msgstr pair for "Isra' and Mi'raj" to the PO file (place it
after the "Eid al-Adha" entry to match the locale order); use the Arabic
translation "الإسراء والمعراج" for msgstr so the msgid "Isra' and Mi'raj" has a
proper localized string.
|
@Prabhu-bit, are you planning to finish this PR? |
|
Just I wanted to contribute as a beginner , thanks for reviews |
|
As I understand it, that's "no" answer. 🤷♂️ |
This PR adds Arabic (ar) localization for Somalia (SO) holidays.
Localization: Added full Arabic translations in holidays/locale/ar/ for all Somalia public holidays.
Testing: Updated tests/countries/test_somalia.py to include localization tests for the Arabic locale.
Verification: All 19 tests (including the new Arabic assertion tests) pass locally.
[x]