Skip to content

Commit

Permalink
Add week timeframe to Polish locale (#769)
Browse files Browse the repository at this point in the history
* add week timeframes to Polish locale

* fix Polish locale

* fix lint errors

Co-authored-by: Chris <30196510+systemcatch@users.noreply.github.com>
  • Loading branch information
akwodkiewicz and systemcatch authored Apr 7, 2020
1 parent 8d8b526 commit 9a1df21
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 8 deletions.
16 changes: 10 additions & 6 deletions arrow/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -1242,20 +1242,24 @@ class PolishLocale(SlavicBaseLocale):
past = "{0} temu"
future = "za {0}"

# The nouns should be in genitive case (Polish: "dopełniacz")
# in order to correctly form `past` & `future` expressions.
timeframes = {
"now": "teraz",
"second": "sekunda",
"seconds": "{0} kilka sekund",
"second": "sekundę",
"seconds": ["{0} sekund", "{0} sekundy", "{0} sekund"],
"minute": "minutę",
"minutes": ["{0} minut", "{0} minuty", "{0} minut"],
"hour": "godzina",
"hour": "godzinę",
"hours": ["{0} godzin", "{0} godziny", "{0} godzin"],
"day": "dzień",
"days": ["{0} dzień", "{0} dni", "{0} dni"],
"days": "{0} dni",
"week": "tydzień",
"weeks": ["{0} tygodni", "{0} tygodnie", "{0} tygodni"],
"month": "miesiąc",
"months": ["{0} miesiąc", "{0} miesiące", "{0} miesięcy"],
"months": ["{0} miesięcy", "{0} miesiące", "{0} miesięcy"],
"year": "rok",
"years": ["{0} rok", "{0} lata", "{0} lat"],
"years": ["{0} lat", "{0} lata", "{0} lat"],
}

month_names = [
Expand Down
44 changes: 42 additions & 2 deletions tests/test_locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,55 @@ def test_plurals2(self):
@pytest.mark.usefixtures("lang_locale")
class TestPolishLocale:
def test_plurals(self):

assert self.locale._format_timeframe("seconds", 0) == "0 sekund"
assert self.locale._format_timeframe("second", 1) == "sekundę"
assert self.locale._format_timeframe("seconds", 2) == "2 sekundy"
assert self.locale._format_timeframe("seconds", 5) == "5 sekund"
assert self.locale._format_timeframe("seconds", 21) == "21 sekund"
assert self.locale._format_timeframe("seconds", 22) == "22 sekundy"
assert self.locale._format_timeframe("seconds", 25) == "25 sekund"

assert self.locale._format_timeframe("minutes", 0) == "0 minut"
assert self.locale._format_timeframe("minute", 1) == "minutę"
assert self.locale._format_timeframe("minutes", 2) == "2 minuty"
assert self.locale._format_timeframe("minutes", 5) == "5 minut"
assert self.locale._format_timeframe("minutes", 21) == "21 minut"
assert self.locale._format_timeframe("minutes", 22) == "22 minuty"
assert self.locale._format_timeframe("minutes", 25) == "25 minut"

assert self.locale._format_timeframe("hours", 0) == "0 godzin"
assert self.locale._format_timeframe("hours", 1) == "1 godzin"
assert self.locale._format_timeframe("hour", 1) == "godzinę"
assert self.locale._format_timeframe("hours", 2) == "2 godziny"
assert self.locale._format_timeframe("hours", 4) == "4 godziny"
assert self.locale._format_timeframe("hours", 5) == "5 godzin"
assert self.locale._format_timeframe("hours", 21) == "21 godzin"
assert self.locale._format_timeframe("hours", 22) == "22 godziny"
assert self.locale._format_timeframe("hours", 25) == "25 godzin"

assert self.locale._format_timeframe("weeks", 0) == "0 tygodni"
assert self.locale._format_timeframe("week", 1) == "tydzień"
assert self.locale._format_timeframe("weeks", 2) == "2 tygodnie"
assert self.locale._format_timeframe("weeks", 5) == "5 tygodni"
assert self.locale._format_timeframe("weeks", 21) == "21 tygodni"
assert self.locale._format_timeframe("weeks", 22) == "22 tygodnie"
assert self.locale._format_timeframe("weeks", 25) == "25 tygodni"

assert self.locale._format_timeframe("months", 0) == "0 miesięcy"
assert self.locale._format_timeframe("month", 1) == "miesiąc"
assert self.locale._format_timeframe("months", 2) == "2 miesiące"
assert self.locale._format_timeframe("months", 5) == "5 miesięcy"
assert self.locale._format_timeframe("months", 21) == "21 miesięcy"
assert self.locale._format_timeframe("months", 22) == "22 miesiące"
assert self.locale._format_timeframe("months", 25) == "25 miesięcy"

assert self.locale._format_timeframe("years", 0) == "0 lat"
assert self.locale._format_timeframe("year", 1) == "rok"
assert self.locale._format_timeframe("years", 2) == "2 lata"
assert self.locale._format_timeframe("years", 5) == "5 lat"
assert self.locale._format_timeframe("years", 21) == "21 lat"
assert self.locale._format_timeframe("years", 22) == "22 lata"
assert self.locale._format_timeframe("years", 25) == "25 lat"


@pytest.mark.usefixtures("lang_locale")
class TestIcelandicLocale:
Expand Down

0 comments on commit 9a1df21

Please sign in to comment.