Repository: crsmithdev/arrow
Pull request #788 (2020-05-13 19:16:04)

Add support for week for the Slovak locale and complete the tests

## Pull Request Checklist

Thank you for taking the time to improve Arrow! Before submitting your pull request, please check all *appropriate* boxes:

<!-- Check boxes by placing an x in the brackets: [x] -->
- [x] 🧪 Added **tests** for changed code.
- [x] 🛠️ All tests **pass** when run locally (run `tox` or `make test` to find out!).
- [x] 🧹 All linting checks **pass** when run locally (run `tox -e lint` or `make lint` to find out!).
- [x] 📚 Updated **documentation** for changed code.
- [x] ⏩ Code is **up-to-date** with the `master` branch.

If you have *any* questions about your code changes or any of the points above, please submit your questions along with the pull request and we will try our best to help!

## Description of Changes

Add support for week for the Slovak locale, fix a translation error (“druhý” in Slovak means “second” like “the one after the first one”, not a short time unit; as well as “pár” means “a couple” and not a specific number) and complete the tests to cover all time units and all cases of a Slavic language.


Patch:
diff --git a/arrow/locales.py b/arrow/locales.py
index b57e3ba..7654419 100644
--- a/arrow/locales.py
+++ b/arrow/locales.py
@@ -2948,14 +2948,16 @@ class SlovakLocale(Locale):
 
     timeframes = {
         "now": "Teraz",
-        "second": {"past": "druhý", "future": "druhý", "zero": "druhý"},
-        "seconds": {"past": "pár sekundami", "future": ["{0} sekundy", "{0} sekúnd"]},
+        "second": {"past": "sekundou", "future": "sekundu", "zero": "{0} sekúnd"},
+        "seconds": {"past": "{0} sekundami", "future": ["{0} sekundy", "{0} sekúnd"]},
         "minute": {"past": "minútou", "future": "minútu", "zero": "{0} minút"},
         "minutes": {"past": "{0} minútami", "future": ["{0} minúty", "{0} minút"]},
         "hour": {"past": "hodinou", "future": "hodinu", "zero": "{0} hodín"},
         "hours": {"past": "{0} hodinami", "future": ["{0} hodiny", "{0} hodín"]},
         "day": {"past": "dňom", "future": "deň", "zero": "{0} dní"},
         "days": {"past": "{0} dňami", "future": ["{0} dni", "{0} dní"]},
+        "week": {"past": "týždňom", "future": "týždeň", "zero": "{0} týždňov"},
+        "weeks": {"past": "{0} týždňami", "future": ["{0} týždne", "{0} týždňov"]},
         "month": {"past": "mesiacom", "future": "mesiac", "zero": "{0} mesiacov"},
         "months": {"past": "{0} mesiacmi", "future": ["{0} mesiace", "{0} mesiacov"]},
         "year": {"past": "rokom", "future": "rok", "zero": "{0} rokov"},


Test patch:
diff --git a/tests/test_locales.py b/tests/test_locales.py
index 0e749a8..96f34ed 100644
--- a/tests/test_locales.py
+++ b/tests/test_locales.py
@@ -372,11 +372,62 @@ class TestCzechLocale:
 class TestSlovakLocale:
     def test_format_timeframe(self):
 
+        assert self.locale._format_timeframe("seconds", -5) == "5 sekundami"
+        assert self.locale._format_timeframe("seconds", -2) == "2 sekundami"
+        assert self.locale._format_timeframe("second", -1) == "sekundou"
+        assert self.locale._format_timeframe("second", 0) == "0 sekúnd"
+        assert self.locale._format_timeframe("second", 1) == "sekundu"
+        assert self.locale._format_timeframe("seconds", 2) == "2 sekundy"
+        assert self.locale._format_timeframe("seconds", 5) == "5 sekúnd"
+
+        assert self.locale._format_timeframe("minutes", -5) == "5 minútami"
+        assert self.locale._format_timeframe("minutes", -2) == "2 minútami"
+        assert self.locale._format_timeframe("minute", -1) == "minútou"
+        assert self.locale._format_timeframe("minute", 0) == "0 minút"
+        assert self.locale._format_timeframe("minute", 1) == "minútu"
+        assert self.locale._format_timeframe("minutes", 2) == "2 minúty"
+        assert self.locale._format_timeframe("minutes", 5) == "5 minút"
+
+        assert self.locale._format_timeframe("hours", -5) == "5 hodinami"
+        assert self.locale._format_timeframe("hours", -2) == "2 hodinami"
+        assert self.locale._format_timeframe("hour", -1) == "hodinou"
+        assert self.locale._format_timeframe("hour", 0) == "0 hodín"
+        assert self.locale._format_timeframe("hour", 1) == "hodinu"
         assert self.locale._format_timeframe("hours", 2) == "2 hodiny"
         assert self.locale._format_timeframe("hours", 5) == "5 hodín"
-        assert self.locale._format_timeframe("hour", 0) == "0 hodín"
-        assert self.locale._format_timeframe("hours", -2) == "2 hodinami"
-        assert self.locale._format_timeframe("hours", -5) == "5 hodinami"
+
+        assert self.locale._format_timeframe("days", -5) == "5 dňami"
+        assert self.locale._format_timeframe("days", -2) == "2 dňami"
+        assert self.locale._format_timeframe("day", -1) == "dňom"
+        assert self.locale._format_timeframe("day", 0) == "0 dní"
+        assert self.locale._format_timeframe("day", 1) == "deň"
+        assert self.locale._format_timeframe("days", 2) == "2 dni"
+        assert self.locale._format_timeframe("days", 5) == "5 dní"
+
+        assert self.locale._format_timeframe("weeks", -5) == "5 týždňami"
+        assert self.locale._format_timeframe("weeks", -2) == "2 týždňami"
+        assert self.locale._format_timeframe("week", -1) == "týždňom"
+        assert self.locale._format_timeframe("week", 0) == "0 týždňov"
+        assert self.locale._format_timeframe("week", 1) == "týždeň"
+        assert self.locale._format_timeframe("weeks", 2) == "2 týždne"
+        assert self.locale._format_timeframe("weeks", 5) == "5 týždňov"
+
+        assert self.locale._format_timeframe("months", -5) == "5 mesiacmi"
+        assert self.locale._format_timeframe("months", -2) == "2 mesiacmi"
+        assert self.locale._format_timeframe("month", -1) == "mesiacom"
+        assert self.locale._format_timeframe("month", 0) == "0 mesiacov"
+        assert self.locale._format_timeframe("month", 1) == "mesiac"
+        assert self.locale._format_timeframe("months", 2) == "2 mesiace"
+        assert self.locale._format_timeframe("months", 5) == "5 mesiacov"
+
+        assert self.locale._format_timeframe("years", -5) == "5 rokmi"
+        assert self.locale._format_timeframe("years", -2) == "2 rokmi"
+        assert self.locale._format_timeframe("year", -1) == "rokom"
+        assert self.locale._format_timeframe("year", 0) == "0 rokov"
+        assert self.locale._format_timeframe("year", 1) == "rok"
+        assert self.locale._format_timeframe("years", 2) == "2 roky"
+        assert self.locale._format_timeframe("years", 5) == "5 rokov"
+
         assert self.locale._format_timeframe("now", 0) == "Teraz"
 
     def test_format_relative_now(self):