Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Urdu locale #1046

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions arrow/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,6 @@
"ta",
"ta-in",
"ta-lk",
"ur",
"ur-pk",
}
81 changes: 81 additions & 0 deletions arrow/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
"",
"سوموار",
"منگل",
"بدھ",
"جمعرات",
"جمعہ",
"ہفتہ",
"اتوار",
]
2 changes: 2 additions & 0 deletions tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2420,6 +2420,8 @@ def locale_list_no_weeks():
"ta",
"ta-in",
"ta-lk",
"ur",
"ur-pk",
]

return tested_langs
Expand Down
30 changes: 30 additions & 0 deletions tests/test_locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down