Skip to content

Commit

Permalink
Merge branch 'macostea-romanian_locale'
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Elkins committed Nov 27, 2016
2 parents ac0e403 + cf49123 commit bb9f897
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
29 changes: 29 additions & 0 deletions arrow/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -1859,4 +1859,33 @@ class SwissLocale(Locale):
]


class RomanianLocale(Locale):
names = ['ro', 'ro_ro']

past = '{0} în urmă'
future = 'peste {0}'

timeframes = {
'now': 'acum',
'seconds': 'câteva secunde',
'minute': 'un minut',
'minutes': '{0} minute',
'hour': 'o oră',
'hours': '{0} ore',
'day': 'o zi',
'days': '{0} zile',
'month': 'o lună',
'months': '{0} luni',
'year': 'un an',
'years': '{0} ani',
}

month_names = ['', 'ianuarie', 'februarie', 'martie', 'aprilie', 'mai', 'iunie', 'iulie',
'august', 'septembrie', 'octombrie', 'noiembrie', 'decembrie']
month_abbreviations = ['', 'ian', 'febr', 'mart', 'apr', 'mai', 'iun', 'iul', 'aug', 'sept', 'oct', 'nov', 'dec']

day_names = ['', 'luni', 'marți', 'miercuri', 'joi', 'vineri', 'sâmbătă', 'duminică']
day_abbreviations = ['', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sâm', 'Dum']


_locales = _map_locales()
32 changes: 32 additions & 0 deletions tests/locales_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,35 @@ def test_ordinal_number(self):
assertEqual(self.locale._format_timeframe('minute', 1), 'einer Minute')
assertEqual(self.locale._format_timeframe('hour', 1), 'einer Stunde')
assertEqual(self.locale.day_abbreviation(dt.isoweekday()), 'Sa')


class RomanianLocaleTests(Chai):

def setUp(self):
super(RomanianLocaleTests, self).setUp()

self.locale = locales.RomanianLocale()

def test_timeframes(self):

self.assertEqual(self.locale._format_timeframe('hours', 2), '2 ore')
self.assertEqual(self.locale._format_timeframe('months', 2), '2 luni')

self.assertEqual(self.locale._format_timeframe('days', 2), '2 zile')
self.assertEqual(self.locale._format_timeframe('years', 2), '2 ani')

self.assertEqual(self.locale._format_timeframe('hours', 3), '3 ore')
self.assertEqual(self.locale._format_timeframe('months', 4), '4 luni')
self.assertEqual(self.locale._format_timeframe('days', 3), '3 zile')
self.assertEqual(self.locale._format_timeframe('years', 5), '5 ani')

def test_relative_timeframes(self):
self.assertEqual(self.locale._format_relative("acum", "now", 0), "acum")
self.assertEqual(self.locale._format_relative("o oră", "hour", 1), "peste o oră")
self.assertEqual(self.locale._format_relative("o oră", "hour", -1), "o oră în urmă")
self.assertEqual(self.locale._format_relative("un minut", "minute", 1), "peste un minut")
self.assertEqual(self.locale._format_relative("un minut", "minute", -1), "un minut în urmă")
self.assertEqual(self.locale._format_relative("câteva secunde", "seconds", -1), "câteva secunde în urmă")
self.assertEqual(self.locale._format_relative("câteva secunde", "seconds", 1), "peste câteva secunde")
self.assertEqual(self.locale._format_relative("o zi", "day", -1), "o zi în urmă")
self.assertEqual(self.locale._format_relative("o zi", "day", 1), "peste o zi")

0 comments on commit bb9f897

Please sign in to comment.