diff --git a/arrow/constants.py b/arrow/constants.py index 085ec392..e41ffa5d 100644 --- a/arrow/constants.py +++ b/arrow/constants.py @@ -143,4 +143,6 @@ "ta", "ta-in", "ta-lk", + "ur", + "ur-pk", } diff --git a/arrow/locales.py b/arrow/locales.py index 48413276..32be55ab 100644 --- a/arrow/locales.py +++ b/arrow/locales.py @@ -5806,3 +5806,84 @@ def describe( "අ", "ඉරිදා", ] + + +class UrduLocale(Locale): + + names = ["ur", "ur-pk"] + + past = "پہلے {0}" + future = "میں {0}" + and_word = "اور" + + timeframes = { + "now": "ابھی", + "second": "ایک سیکنڈ", + "seconds": "{0} سیکنڈ", + "minute": "ایک منٹ", + "minutes": "{0} منٹ", + "hour": "ایک گھنٹے", + "hours": "{0} گھنٹے", + "day": "ایک دن", + "days": "{0} دن", + "week": "ایک ہفتے", + "weeks": "{0} ہفتے", + "month": "ایک مہینہ", + "months": "{0} ماہ", + "year": "ایک سال", + "years": "{0} سال", + } + + month_names = [ + "", + "جنوری", + "فروری", + "مارچ", + "اپریل", + "مئی", + "جون", + "جولائی", + "اگست", + "ستمبر", + "اکتوبر", + "نومبر", + "دسمبر", + ] + + month_abbreviations = [ + "", + "جنوری", + "فروری", + "مارچ", + "اپریل", + "مئی", + "جون", + "جولائی", + "اگست", + "ستمبر", + "اکتوبر", + "نومبر", + "دسمبر", + ] + + day_names = [ + "", + "سوموار", + "منگل", + "بدھ", + "جمعرات", + "جمعہ", + "ہفتہ", + "اتوار", + ] + + day_abbreviations = [ + "", + "سوموار", + "منگل", + "بدھ", + "جمعرات", + "جمعہ", + "ہفتہ", + "اتوار", + ] diff --git a/tests/test_arrow.py b/tests/test_arrow.py index 732cd79c..0314ffae 100644 --- a/tests/test_arrow.py +++ b/tests/test_arrow.py @@ -2420,6 +2420,8 @@ def locale_list_no_weeks(): "ta", "ta-in", "ta-lk", + "ur", + "ur-pk", ] return tested_langs diff --git a/tests/test_locales.py b/tests/test_locales.py index f7aa17a9..0401f7bf 100644 --- a/tests/test_locales.py +++ b/tests/test_locales.py @@ -1422,6 +1422,36 @@ def test_weekday_and_month(self): assert self.locale.month_abbreviation(dt.isoweekday()) == "qer" +@pytest.mark.usefixtures("lang_locale") +class TestUrduLocale: + def test_format_timeframe(self): + assert self.locale._format_timeframe("now", 0) == "ابھی" + assert self.locale._format_timeframe("second", -1) == "ایک سیکنڈ" + assert self.locale._format_timeframe("second", 1) == "ایک سیکنڈ" + assert self.locale._format_timeframe("seconds", -3) == "3 سیکنڈ" + assert self.locale._format_timeframe("minute", 1) == "ایک منٹ" + assert self.locale._format_timeframe("minutes", -4) == "4 منٹ" + assert self.locale._format_timeframe("hour", 1) == "ایک گھنٹے" + assert self.locale._format_timeframe("hours", -23) == "23 گھنٹے" + assert self.locale._format_timeframe("day", 1) == "ایک دن" + assert self.locale._format_timeframe("days", -12) == "12 دن" + assert self.locale._format_timeframe("week", 1) == "ایک ہفتے" + assert self.locale._format_timeframe("weeks", -12) == "12 ہفتے" + assert self.locale._format_timeframe("month", 1) == "ایک مہینہ" + assert self.locale._format_timeframe("months", -2) == "2 ماہ" + assert self.locale._format_timeframe("year", 1) == "ایک سال" + assert self.locale._format_timeframe("years", -2) == "2 سال" + + def test_weekday_and_month(self): + dt = arrow.Arrow(2015, 4, 11, 17, 30, 00) + # Saturday + assert self.locale.day_name(dt.isoweekday()) == "ہفتہ" + assert self.locale.day_abbreviation(dt.isoweekday()) == "ہفتہ" + # June + assert self.locale.month_name(dt.isoweekday()) == "جون" + assert self.locale.month_abbreviation(dt.isoweekday()) == "جون" + + @pytest.mark.usefixtures("lang_locale") class TestEstonianLocale: def test_format_timeframe(self):