Skip to content

Commit

Permalink
Add Odia (or) locale (#966)
Browse files Browse the repository at this point in the history
* Add Odia (or) locale

* Fix formatting with black

* Improve Odia translation

* Add a few more tests
  • Loading branch information
snmishra authored Apr 29, 2021
1 parent 08705bc commit fe1aaae
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 0 deletions.
2 changes: 2 additions & 0 deletions arrow/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,6 @@
"ms",
"ms-my",
"ms-bn",
"or",
"or-in",
}
91 changes: 91 additions & 0 deletions arrow/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -4800,3 +4800,94 @@ class MalayLocale(Locale):
"Sabtu",
"Ahad ",
]


class OdiaLocale(Locale):

names = ["or", "or-in"]

past = "{0} ପୂର୍ବେ"
future = "{0} ପରେ"

timeframes = {
"now": "ବର୍ତ୍ତମାନ",
"second": "ଏକ ସେକେଣ୍ଡ",
"seconds": "{0} ସେକେଣ୍ଡ",
"minute": "ଏକ ମିନଟ",
"minutes": "{0} ମିନଟ",
"hour": "ଏକ ଘଣ୍ଟା",
"hours": "{0} ଘଣ୍ଟା",
"day": "ଏକ ଦିନ",
"days": "{0} ଦିନ",
"month": "ଏକ ମାସ",
"months": "{0} ମାସ ",
"year": "ଏକ ବର୍ଷ",
"years": "{0} ବର୍ଷ",
}

meridians = {"am": "ପୂର୍ବାହ୍ନ", "pm": "ଅପରାହ୍ନ", "AM": "ପୂର୍ବାହ୍ନ", "PM": "ଅପରାହ୍ନ"}

month_names = [
"",
"ଜାନୁଆରୀ",
"ଫେବୃଆରୀ",
"ମାର୍ଚ୍ଚ୍",
"ଅପ୍ରେଲ",
"ମଇ",
"ଜୁନ୍",
"ଜୁଲାଇ",
"ଅଗଷ୍ଟ",
"ସେପ୍ଟେମ୍ବର",
"ଅକ୍ଟୋବର୍",
"ନଭେମ୍ବର୍",
"ଡିସେମ୍ବର୍",
]
month_abbreviations = [
"",
"ଜାନୁ",
"ଫେବୃ",
"ମାର୍ଚ୍ଚ୍",
"ଅପ୍ରେ",
"ମଇ",
"ଜୁନ୍",
"ଜୁଲା",
"ଅଗ",
"ସେପ୍ଟେ",
"ଅକ୍ଟୋ",
"ନଭେ",
"ଡିସେ",
]

day_names = [
"",
"ସୋମବାର",
"ମଙ୍ଗଳବାର",
"ବୁଧବାର",
"ଗୁରୁବାର",
"ଶୁକ୍ରବାର",
"ଶନିବାର",
"ରବିବାର",
]
day_abbreviations = [
"",
"ସୋମ",
"ମଙ୍ଗଳ",
"ବୁଧ",
"ଗୁରୁ",
"ଶୁକ୍ର",
"ଶନି",
"ରବି",
]

def _ordinal_number(self, n: int) -> str:
if n > 10 or n == 0:
return f"{n}ତମ"
if n in [1, 5, 7, 8, 9, 10]:
return f"{n}ମ"
if n in [2, 3]:
return f"{n}ୟ"
if n == 4:
return f"{n}ର୍ଥ"
if n == 6:
return f"{n}ଷ୍ଠ"
return ""
2 changes: 2 additions & 0 deletions tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2380,6 +2380,8 @@ def locale_list_no_weeks():
"ms",
"ms-my",
"ms-bn",
"or",
"or-in",
]

return tested_langs
Expand Down
35 changes: 35 additions & 0 deletions tests/test_locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -1549,3 +1549,38 @@ def test_plurals(self):
assert self.locale._format_timeframe("months", 11) == "11 månader"
assert self.locale._format_timeframe("year", 1) == "ett år"
assert self.locale._format_timeframe("years", 12) == "12 år"


@pytest.mark.usefixtures("lang_locale")
class TestOdiaLocale:
def test_ordinal_number(self):
assert self.locale._ordinal_number(0) == "0ତମ"
assert self.locale._ordinal_number(1) == "1ମ"
assert self.locale._ordinal_number(3) == "3ୟ"
assert self.locale._ordinal_number(4) == "4ର୍ଥ"
assert self.locale._ordinal_number(5) == "5ମ"
assert self.locale._ordinal_number(6) == "6ଷ୍ଠ"
assert self.locale._ordinal_number(10) == "10ମ"
assert self.locale._ordinal_number(11) == "11ତମ"
assert self.locale._ordinal_number(42) == "42ତମ"
assert self.locale._ordinal_number(-1) == ""

def test_format_timeframe(self):

assert self.locale._format_timeframe("hours", 2) == "2 ଘଣ୍ଟା"
assert self.locale._format_timeframe("hour", 0) == "ଏକ ଘଣ୍ଟା"

def test_format_relative_now(self):

result = self.locale._format_relative("ବର୍ତ୍ତମାନ", "now", 0)
assert result == "ବର୍ତ୍ତମାନ"

def test_format_relative_past(self):

result = self.locale._format_relative("ଏକ ଘଣ୍ଟା", "hour", 1)
assert result == "ଏକ ଘଣ୍ଟା ପରେ"

def test_format_relative_future(self):

result = self.locale._format_relative("ଏକ ଘଣ୍ଟା", "hour", -1)
assert result == "ଏକ ଘଣ୍ଟା ପୂର୍ବେ"

0 comments on commit fe1aaae

Please sign in to comment.