Skip to content

Commit

Permalink
Merge pull request #194 from doodyparizada/master
Browse files Browse the repository at this point in the history
Add Hebrew Locale. Thanks @doodyparizada
  • Loading branch information
andrewelkins committed Jan 27, 2015
2 parents f7f9ef3 + 0e16d73 commit 859a449
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
50 changes: 50 additions & 0 deletions arrow/locales.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,56 @@ class MacedonianLocale(Locale):
day_abbreviations = ['', 'ะŸะพะฝ.', ' ะ’ั‚.', ' ะกั€ะต.', ' ะงะตั‚.', ' ะŸะตั‚.', ' ะกะฐะฑ.', ' ะะตะด.']


class HebrewLocale(Locale):

names = ['he', 'he_IL']

past = 'ืœืคื ื™ {0}'
future = 'ื‘ืขื•ื“ {0}'

timeframes = {
'now': 'ื”ืจื’ืข',
'seconds': 'ืฉื ื™ื•ืช',
'minute': 'ื“ืงื”',
'minutes': '{0} ื“ืงื•ืช',
'hour': 'ืฉืขื”',
'hours': '{0} ืฉืขื•ืช',
'2-hours': 'ืฉืขืชื™ื™ื',
'day': 'ื™ื•ื',
'days': '{0} ื™ืžื™ื',
'2-days': 'ื™ื•ืžื™ื™ื',
'month': 'ื—ื•ื“ืฉ',
'months': '{0} ื—ื•ื“ืฉื™ื',
'2-months': 'ื—ื•ื“ืฉื™ื™ื',
'year': 'ืฉื ื”',
'years': '{0} ืฉื ื™ื',
'2-years': 'ืฉื ืชื™ื™ื',
}

meridians = {
'am': 'ืœืคื "ืฆ',
'pm': 'ืื—ืจ"ืฆ',
'AM': 'ืœืคื ื™ ื”ืฆื”ืจื™ื™ื',
'PM': 'ืื—ืจื™ ื”ืฆื”ืจื™ื™ื',
}

month_names = ['', 'ื™ื ื•ืืจ', 'ืคื‘ืจื•ืืจ', 'ืžืจืฅ', 'ืืคืจื™ืœ', 'ืžืื™', 'ื™ื•ื ื™', 'ื™ื•ืœื™',
'ืื•ื’ื•ืกื˜', 'ืกืคื˜ืžื‘ืจ', 'ืื•ืงื˜ื•ื‘ืจ', 'ื ื•ื‘ืžื‘ืจ', 'ื“ืฆืžื‘ืจ']
month_abbreviations = ['', 'ื™ื ื•ืณ', 'ืคื‘ืจืณ', 'ืžืจืฅ', 'ืืคืจืณ', 'ืžืื™', 'ื™ื•ื ื™', 'ื™ื•ืœื™', 'ืื•ื’ืณ',
'ืกืคื˜ืณ', 'ืื•ืงืณ', 'ื ื•ื‘ืณ', 'ื“ืฆืžืณ']

day_names = ['', 'ืฉื ื™', 'ืฉืœื™ืฉื™', 'ืจื‘ื™ืขื™', 'ื—ืžื™ืฉื™', 'ืฉื™ืฉื™', 'ืฉื‘ืช', 'ืจืืฉื•ืŸ']
day_abbreviations = ['', 'ื‘ืณ', 'ื’ืณ', 'ื“ืณ', 'ื”ืณ', 'ื•ืณ', 'ืฉืณ', 'ืืณ']

def _format_timeframe(self, timeframe, delta):
'''Hebrew couple of <timeframe> aware'''
couple = '2-{0}'.format(timeframe)
if abs(delta) == 2 and couple in self.timeframes:
return self.timeframes[couple].format(abs(delta))
else:
return self.timeframes[timeframe].format(abs(delta))


def _map_locales():

locales = {}
Expand Down
16 changes: 16 additions & 0 deletions tests/locales_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,19 @@ def test_format_relative_past(self):

result = self.locale._format_relative('hodinou', 'hour', -1)
assertEqual(result, 'Pล™ed hodinou')


class HebrewLocaleTests(Chai):

def test_couple_of_timeframe(self):
locale = locales.HebrewLocale()

assertEqual(locale._format_timeframe('hours', 2), 'ืฉืขืชื™ื™ื')
assertEqual(locale._format_timeframe('months', 2), 'ื—ื•ื“ืฉื™ื™ื')
assertEqual(locale._format_timeframe('days', 2), 'ื™ื•ืžื™ื™ื')
assertEqual(locale._format_timeframe('years', 2), 'ืฉื ืชื™ื™ื')

assertEqual(locale._format_timeframe('hours', 3), '3 ืฉืขื•ืช')
assertEqual(locale._format_timeframe('months', 4), '4 ื—ื•ื“ืฉื™ื')
assertEqual(locale._format_timeframe('days', 3), '3 ื™ืžื™ื')
assertEqual(locale._format_timeframe('years', 5), '5 ืฉื ื™ื')

0 comments on commit 859a449

Please sign in to comment.