Permalink
Browse files

Add Icelandic locale with tests

The Icelandic timeframes have different declensions
depending on if we are formating for the past or the future.
  • Loading branch information...
1 parent 01e93c9 commit 750e1445ed5963c58437011813a4352a497b9ddc @holmars holmars committed Feb 12, 2014
Showing with 59 additions and 0 deletions.
  1. +43 −0 arrow/locales.py
  2. +16 −0 tests/locales_tests.py
View
@@ -892,6 +892,49 @@ class ArabicLocale(Locale):
day_names = ['', 'الاثنين', 'الثلاثاء', 'الأربعاء', 'الخميس', 'الجمعة', 'السبت', 'الأحد']
day_abbreviations = ['', 'اثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت', 'أحد']
+
+class IcelandicLocale(Locale):
+
+ def _format_timeframe(self, timeframe, delta):
+
+ timeframe = self.timeframes[timeframe]
+ if delta < 0:
+ timeframe = timeframe[0]
+ elif delta > 0:
+ timeframe = timeframe[1]
+
+ return timeframe.format(abs(delta))
+
+ names = ['is', 'is_is']
+
+ past = 'fyrir {0} síðan'
+ future = 'eftir {0}'
+
+ timeframes = {
+ 'now': 'rétt í þessu',
+ 'seconds': ('nokkrum sekúndum', 'nokkrar sekúndur'),
+ 'minute': ('einni mínútu', 'eina mínútu'),
+ 'minutes': ('{0} mínútum', '{0} mínútur'),
+ 'hour': ('einum tíma', 'einn tíma'),
+ 'hours': ('{0} tímum', '{0} tíma'),
+ 'day': ('einum degi', 'einn dag'),
+ 'days': ('{0} dögum', '{0} daga'),
+ 'month': ('einum mánuði', 'einn mánuð'),
+ 'months': ('{0} mánuðum', '{0} mánuði'),
+ 'year': ('einu ári', 'eitt ár'),
+ 'years': ('{0} árum', '{0} ár'),
+ }
+
+ month_names = ['', 'janúar', 'febrúar', 'mars', 'apríl', 'maí', 'júní',
+ 'júlí', 'ágúst', 'september', 'október', 'nóvember', 'desember']
+ month_abbreviations = ['', 'jan', 'feb', 'mar', 'apr', 'maí', 'jún',
+ 'júl', 'ágú', 'sep', 'okt', 'nóv', 'des']
+
+ day_names = ['', 'mánudagur', 'þriðjudagur', 'miðvikudagur', 'fimmtudagur',
+ 'föstudagur', 'laugardagur', 'sunnudagur']
+ day_abbreviations = ['', 'mán', 'þri', 'mið', 'fim', 'fös', 'lau', 'sun']
+
+
def _map_locales():
locales = {}
View
@@ -97,3 +97,19 @@ def test_plurals(self):
assertEqual(locale._format_timeframe('hours', 21), '21 godzin')
assertEqual(locale._format_timeframe('hours', 22), '22 godziny')
assertEqual(locale._format_timeframe('hours', 25), '25 godzin')
+
+
+class IcelandicLocalesTests(Chai):
+
+ def setUp(self):
+ super(IcelandicLocalesTests, self).setUp()
+
+ self.locale = locales.IcelandicLocale()
+
+ def test_format_timeframe(self):
+
+ assertEqual(self.locale._format_timeframe('minute', -1), 'einni mínútu')
+ assertEqual(self.locale._format_timeframe('minute', 1), 'eina mínútu')
+
+ assertEqual(self.locale._format_timeframe('hours', -2), '2 tímum')
+ assertEqual(self.locale._format_timeframe('hours', 2), '2 tíma')

0 comments on commit 750e144

Please sign in to comment.