From a8250f3a73558babe29503e7070f19578df54d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20W=C3=B3dkiewicz?= Date: Sun, 5 Apr 2020 18:48:57 +0200 Subject: [PATCH 1/3] add week timeframes to Polish locale --- arrow/locales.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arrow/locales.py b/arrow/locales.py index 55f19d12a..367f9e984 100644 --- a/arrow/locales.py +++ b/arrow/locales.py @@ -1237,6 +1237,8 @@ class PolishLocale(SlavicBaseLocale): "hours": ["{0} godzin", "{0} godziny", "{0} godzin"], "day": "dzień", "days": ["{0} dzień", "{0} dni", "{0} dni"], + "week": "tydzień", + "weeks": ["{0} tygodni", "{0} tygodnie", "{0} tygodni"], "month": "miesiąc", "months": ["{0} miesiąc", "{0} miesiące", "{0} miesięcy"], "year": "rok", From 35c54b7660313c972c50287af9dcb8bcbb6b25b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20W=C3=B3dkiewicz?= Date: Sun, 5 Apr 2020 18:48:16 +0200 Subject: [PATCH 2/3] fix Polish locale --- arrow/locales.py | 14 ++++++++------ tests/test_locales.py | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/arrow/locales.py b/arrow/locales.py index 367f9e984..59fe433cb 100644 --- a/arrow/locales.py +++ b/arrow/locales.py @@ -1227,22 +1227,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 = [ diff --git a/tests/test_locales.py b/tests/test_locales.py index 6002968f6..06bf43597 100644 --- a/tests/test_locales.py +++ b/tests/test_locales.py @@ -236,15 +236,53 @@ def test_plurals(self): locale = locales.PolishLocale() + assert locale._format_timeframe("seconds", 0) == "0 sekund" + assert locale._format_timeframe("second", 1) == "sekundę" + assert locale._format_timeframe("seconds", 2) == "2 sekundy" + assert locale._format_timeframe("seconds", 5) == "5 sekund" + assert locale._format_timeframe("seconds", 21) == "21 sekund" + assert locale._format_timeframe("seconds", 22) == "22 sekundy" + assert locale._format_timeframe("seconds", 25) == "25 sekund" + + assert locale._format_timeframe("minutes", 0) == "0 minut" + assert locale._format_timeframe("minute", 1) == "minutę" + assert locale._format_timeframe("minutes", 2) == "2 minuty" + assert locale._format_timeframe("minutes", 5) == "5 minut" + assert locale._format_timeframe("minutes", 21) == "21 minut" + assert locale._format_timeframe("minutes", 22) == "22 minuty" + assert locale._format_timeframe("minutes", 25) == "25 minut" + assert locale._format_timeframe("hours", 0) == "0 godzin" - assert locale._format_timeframe("hours", 1) == "1 godzin" + assert locale._format_timeframe("hour", 1) == "godzinę" assert locale._format_timeframe("hours", 2) == "2 godziny" - assert locale._format_timeframe("hours", 4) == "4 godziny" assert locale._format_timeframe("hours", 5) == "5 godzin" assert locale._format_timeframe("hours", 21) == "21 godzin" assert locale._format_timeframe("hours", 22) == "22 godziny" assert locale._format_timeframe("hours", 25) == "25 godzin" + assert locale._format_timeframe("weeks", 0) == "0 tygodni" + assert locale._format_timeframe("week", 1) == "tydzień" + assert locale._format_timeframe("weeks", 2) == "2 tygodnie" + assert locale._format_timeframe("weeks", 5) == "5 tygodni" + assert locale._format_timeframe("weeks", 21) == "21 tygodni" + assert locale._format_timeframe("weeks", 22) == "22 tygodnie" + assert locale._format_timeframe("weeks", 25) == "25 tygodni" + + assert locale._format_timeframe("months", 0) == "0 miesięcy" + assert locale._format_timeframe("month", 1) == "miesiąc" + assert locale._format_timeframe("months", 2) == "2 miesiące" + assert locale._format_timeframe("months", 5) == "5 miesięcy" + assert locale._format_timeframe("months", 21) == "21 miesięcy" + assert locale._format_timeframe("months", 22) == "22 miesiące" + assert locale._format_timeframe("months", 25) == "25 miesięcy" + + assert locale._format_timeframe("years", 0) == "0 lat" + assert locale._format_timeframe("year", 1) == "rok" + assert locale._format_timeframe("years", 2) == "2 lata" + assert locale._format_timeframe("years", 5) == "5 lat" + assert locale._format_timeframe("years", 21) == "21 lat" + assert locale._format_timeframe("years", 22) == "22 lata" + assert locale._format_timeframe("years", 25) == "25 lat" class TestIcelandicLocales: @classmethod From b372d3338db19ac8d698b74344dc6d76309720aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20W=C3=B3dkiewicz?= Date: Sun, 5 Apr 2020 19:00:49 +0200 Subject: [PATCH 3/3] fix lint errors --- arrow/locales.py | 2 +- tests/test_locales.py | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arrow/locales.py b/arrow/locales.py index 59fe433cb..2bc9159fb 100644 --- a/arrow/locales.py +++ b/arrow/locales.py @@ -1232,7 +1232,7 @@ class PolishLocale(SlavicBaseLocale): timeframes = { "now": "teraz", "second": "sekundę", - "seconds": ["{0} sekund", "{0} sekundy", "{0} sekund"], + "seconds": ["{0} sekund", "{0} sekundy", "{0} sekund"], "minute": "minutę", "minutes": ["{0} minut", "{0} minuty", "{0} minut"], "hour": "godzinę", diff --git a/tests/test_locales.py b/tests/test_locales.py index 06bf43597..d93abd264 100644 --- a/tests/test_locales.py +++ b/tests/test_locales.py @@ -237,7 +237,7 @@ def test_plurals(self): locale = locales.PolishLocale() assert locale._format_timeframe("seconds", 0) == "0 sekund" - assert locale._format_timeframe("second", 1) == "sekundę" + assert locale._format_timeframe("second", 1) == "sekundę" assert locale._format_timeframe("seconds", 2) == "2 sekundy" assert locale._format_timeframe("seconds", 5) == "5 sekund" assert locale._format_timeframe("seconds", 21) == "21 sekund" @@ -245,7 +245,7 @@ def test_plurals(self): assert locale._format_timeframe("seconds", 25) == "25 sekund" assert locale._format_timeframe("minutes", 0) == "0 minut" - assert locale._format_timeframe("minute", 1) == "minutę" + assert locale._format_timeframe("minute", 1) == "minutę" assert locale._format_timeframe("minutes", 2) == "2 minuty" assert locale._format_timeframe("minutes", 5) == "5 minut" assert locale._format_timeframe("minutes", 21) == "21 minut" @@ -261,7 +261,7 @@ def test_plurals(self): assert locale._format_timeframe("hours", 25) == "25 godzin" assert locale._format_timeframe("weeks", 0) == "0 tygodni" - assert locale._format_timeframe("week", 1) == "tydzień" + assert locale._format_timeframe("week", 1) == "tydzień" assert locale._format_timeframe("weeks", 2) == "2 tygodnie" assert locale._format_timeframe("weeks", 5) == "5 tygodni" assert locale._format_timeframe("weeks", 21) == "21 tygodni" @@ -269,7 +269,7 @@ def test_plurals(self): assert locale._format_timeframe("weeks", 25) == "25 tygodni" assert locale._format_timeframe("months", 0) == "0 miesięcy" - assert locale._format_timeframe("month", 1) == "miesiąc" + assert locale._format_timeframe("month", 1) == "miesiąc" assert locale._format_timeframe("months", 2) == "2 miesiące" assert locale._format_timeframe("months", 5) == "5 miesięcy" assert locale._format_timeframe("months", 21) == "21 miesięcy" @@ -277,13 +277,14 @@ def test_plurals(self): assert locale._format_timeframe("months", 25) == "25 miesięcy" assert locale._format_timeframe("years", 0) == "0 lat" - assert locale._format_timeframe("year", 1) == "rok" + assert locale._format_timeframe("year", 1) == "rok" assert locale._format_timeframe("years", 2) == "2 lata" assert locale._format_timeframe("years", 5) == "5 lat" assert locale._format_timeframe("years", 21) == "21 lat" assert locale._format_timeframe("years", 22) == "22 lata" assert locale._format_timeframe("years", 25) == "25 lat" + class TestIcelandicLocales: @classmethod def setup_class(cls):