Skip to content

Commit

Permalink
Add Albanian Locale (#1030)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyriaka90 authored Aug 27, 2021
1 parent e9f5f1a commit 44c3930
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arrow/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
"or-in",
"lb",
"lb-lu",
"sq",
"sq-al",
"ta",
"ta-in",
"ta-lk",
Expand Down
81 changes: 81 additions & 0 deletions arrow/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -5528,3 +5528,84 @@ def _ordinal_number(self, n: int) -> str:
return f"{n}ஆம்"
else:
return ""


class AlbanianLocale(Locale):

names = ["sq", "sq-al"]

past = "{0} më parë"
future = "në {0}"
and_word = "dhe"

timeframes = {
"now": "tani",
"second": "sekondë",
"seconds": "{0} sekonda",
"minute": "minutë",
"minutes": "{0} minuta",
"hour": "orë",
"hours": "{0} orë",
"day": "ditë",
"days": "{0} ditë",
"week": "javë",
"weeks": "{0} javë",
"month": "muaj",
"months": "{0} muaj",
"year": "vit",
"years": "{0} vjet",
}

month_names = [
"",
"janar",
"shkurt",
"mars",
"prill",
"maj",
"qershor",
"korrik",
"gusht",
"shtator",
"tetor",
"nëntor",
"dhjetor",
]

month_abbreviations = [
"",
"jan",
"shk",
"mar",
"pri",
"maj",
"qer",
"korr",
"gush",
"sht",
"tet",
"nën",
"dhj",
]

day_names = [
"",
"e hënë",
"e martë",
"e mërkurë",
"e enjte",
"e premte",
"e shtunë",
"e diel",
]

day_abbreviations = [
"",
"hën",
"mar",
"mër",
"enj",
"pre",
"sht",
"die",
]
2 changes: 2 additions & 0 deletions tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,8 @@ def locale_list_no_weeks():
"se-se",
"lb",
"lb-lu",
"sq",
"sq-al",
"ta",
"ta-in",
"ta-lk",
Expand Down
30 changes: 30 additions & 0 deletions tests/test_locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,36 @@ def test_weekday(self):
assert self.locale.day_name(dt.isoweekday()) == "uMgqibelo"


@pytest.mark.usefixtures("lang_locale")
class TestAlbanianLocale:
def test_format_timeframe(self):
assert self.locale._format_timeframe("now", 0) == "tani"
assert self.locale._format_timeframe("second", -1) == "sekondë"
assert self.locale._format_timeframe("second", 1) == "sekondë"
assert self.locale._format_timeframe("seconds", -3) == "3 sekonda"
assert self.locale._format_timeframe("minute", 1) == "minutë"
assert self.locale._format_timeframe("minutes", -4) == "4 minuta"
assert self.locale._format_timeframe("hour", 1) == "orë"
assert self.locale._format_timeframe("hours", -23) == "23 orë"
assert self.locale._format_timeframe("day", 1) == "ditë"
assert self.locale._format_timeframe("days", -12) == "12 ditë"
assert self.locale._format_timeframe("week", 1) == "javë"
assert self.locale._format_timeframe("weeks", -12) == "12 javë"
assert self.locale._format_timeframe("month", 1) == "muaj"
assert self.locale._format_timeframe("months", -2) == "2 muaj"
assert self.locale._format_timeframe("year", 1) == "vit"
assert self.locale._format_timeframe("years", -2) == "2 vjet"

def test_weekday_and_month(self):
dt = arrow.Arrow(2015, 4, 11, 17, 30, 00)
# Saturday
assert self.locale.day_name(dt.isoweekday()) == "e shtunë"
assert self.locale.day_abbreviation(dt.isoweekday()) == "sht"
# June
assert self.locale.month_name(dt.isoweekday()) == "qershor"
assert self.locale.month_abbreviation(dt.isoweekday()) == "qer"


@pytest.mark.usefixtures("lang_locale")
class TestEstonianLocale:
def test_format_timeframe(self):
Expand Down

0 comments on commit 44c3930

Please sign in to comment.