Skip to content

Commit

Permalink
Add Latvian locale (#951)
Browse files Browse the repository at this point in the history
Co-authored-by: Jad Chaar <jadchaar@users.noreply.github.com>
  • Loading branch information
cyriaka90 and jadchaar authored Apr 7, 2021
1 parent 85964d0 commit 485d40b
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
81 changes: 81 additions & 0 deletions arrow/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -4305,6 +4305,87 @@ def _format_timeframe(
return _form.format(abs(delta))


class LatvianLocale(Locale):

names = ["lv", "lv-lv"]

past = "pirms {0}"
future = "pēc {0}"
and_word = "un"

timeframes: ClassVar[Mapping[TimeFrameLiteral, Union[str, Mapping[str, str]]]] = {
"now": "tagad",
"second": "sekundes",
"seconds": "{0} sekundēm",
"minute": "minūtes",
"minutes": "{0} minūtēm",
"hour": "stundas",
"hours": "{0} stundām",
"day": "dienas",
"days": "{0} dienām",
"week": "nedēļas",
"weeks": "{0} nedēļām",
"month": "mēneša",
"months": "{0} mēnešiem",
"year": "gada",
"years": "{0} gadiem",
}

month_names = [
"",
"janvāris",
"februāris",
"marts",
"aprīlis",
"maijs",
"jūnijs",
"jūlijs",
"augusts",
"septembris",
"oktobris",
"novembris",
"decembris",
]

month_abbreviations = [
"",
"jan",
"feb",
"marts",
"apr",
"maijs",
"jūnijs",
"jūlijs",
"aug",
"sept",
"okt",
"nov",
"dec",
]

day_names = [
"",
"pirmdiena",
"otrdiena",
"trešdiena",
"ceturtdiena",
"piektdiena",
"sestdiena",
"svētdiena",
]

day_abbreviations = [
"",
"pi",
"ot",
"tr",
"ce",
"pi",
"se",
"sv",
]


class SwahiliLocale(Locale):

names = [
Expand Down
27 changes: 27 additions & 0 deletions tests/test_locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,33 @@ def test_format_timeframe(self):
assert self.locale._format_timeframe("years", 12) == "12 anos"


@pytest.mark.usefixtures("lang_locale")
class TestLatvianLocale:
def test_format_timeframe(self):
assert self.locale._format_timeframe("now", 0) == "tagad"
assert self.locale._format_timeframe("second", 1) == "sekundes"
assert self.locale._format_timeframe("seconds", 3) == "3 sekundēm"
assert self.locale._format_timeframe("seconds", 30) == "30 sekundēm"
assert self.locale._format_timeframe("minute", 1) == "minūtes"
assert self.locale._format_timeframe("minutes", 4) == "4 minūtēm"
assert self.locale._format_timeframe("minutes", 40) == "40 minūtēm"
assert self.locale._format_timeframe("hour", 1) == "stundas"
assert self.locale._format_timeframe("hours", 23) == "23 stundām"
assert self.locale._format_timeframe("day", 1) == "dienas"
assert self.locale._format_timeframe("days", 12) == "12 dienām"
assert self.locale._format_timeframe("month", 1) == "mēneša"
assert self.locale._format_timeframe("months", 2) == "2 mēnešiem"
assert self.locale._format_timeframe("months", 11) == "11 mēnešiem"
assert self.locale._format_timeframe("year", 1) == "gada"
assert self.locale._format_timeframe("years", 2) == "2 gadiem"
assert self.locale._format_timeframe("years", 12) == "12 gadiem"

def test_weekday(self):
dt = arrow.Arrow(2015, 4, 11, 17, 30, 00)
assert self.locale.day_name(dt.isoweekday()) == "sestdiena"
assert self.locale.day_abbreviation(dt.isoweekday()) == "se"


@pytest.mark.usefixtures("lang_locale")
class TestBrazilianPortugueseLocale:
def test_format_timeframe(self):
Expand Down

0 comments on commit 485d40b

Please sign in to comment.