Skip to content

Commit

Permalink
add French locales for France & Canada
Browse files Browse the repository at this point in the history
  • Loading branch information
ianare committed May 1, 2016
1 parent 5476604 commit 907aae2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
16 changes: 16 additions & 0 deletions moneyed/localization.py
Expand Up @@ -155,6 +155,16 @@ def format(self, money, include_symbol=True, locale=DEFAULT,
negative_sign="-", trailing_negative_sign="",
rounding_method=ROUND_HALF_EVEN)

_format("fr_FR", group_size=3, group_separator=" ", decimal_point=",",
positive_sign="", trailing_positive_sign="",
negative_sign="-", trailing_negative_sign="",
rounding_method=ROUND_HALF_EVEN)

_format("fr_CA", group_size=3, group_separator=" ", decimal_point=",",
positive_sign="", trailing_positive_sign="",
negative_sign="-", trailing_negative_sign="",
rounding_method=ROUND_HALF_EVEN)

_format("sv_SE", group_size=3, group_separator=" ", decimal_point=",",
positive_sign="", trailing_positive_sign="",
negative_sign="-", trailing_negative_sign="",
Expand Down Expand Up @@ -337,6 +347,12 @@ def format(self, money, include_symbol=True, locale=DEFAULT,
_sign('de_DE', moneyed.EUR, suffix=' €')
_sign('de_AT', moneyed.EUR, suffix=' €')
_sign('de_CH', moneyed.CHF, prefix='Fr.')
_sign('fr_FR', moneyed.EUR, suffix=' €')
_sign('fr_FR', moneyed.USD, suffix=' $ US')
_sign('fr_CA', moneyed.USD, suffix=' $ US')
_sign('fr_FR', moneyed.CAD, suffix=' $ CA')
_sign('fr_CA', moneyed.CAD, suffix=' $')
_sign('fr_CA', moneyed.EUR, suffix=' €')

# Adding translations for missing currencies
_sign('en_US', moneyed.KWD, prefix='KD')
Expand Down
15 changes: 15 additions & 0 deletions moneyed/test_moneyed_classes.py
Expand Up @@ -127,6 +127,21 @@ def test_format_money(self):
assert format_money(one_million_pln, locale='pl_PL',
decimal_places=0) == '1 000 000 zł'

def test_format_money_fr(self):
# locale == fr_FR
one_million_eur = Money('1000000', 'EUR')
one_million_cad = Money('1000000', 'CAD')
assert format_money(one_million_eur, locale='fr_FR') == '1 000 000,00 €'
assert format_money(self.one_million_bucks, locale='fr_FR') == '1 000 000,00 $ US'
assert format_money(one_million_cad, locale='fr_FR') == '1 000 000,00 $ CA'
# No decimal point without fractional part
assert format_money(one_million_eur, locale='fr_FR',
decimal_places=0) == '1 000 000 €'
# locale == fr_CA
assert format_money(one_million_cad, locale='fr_CA') == '1 000 000,00 $'
assert format_money(self.one_million_bucks, locale='fr_CA') == '1 000 000,00 $ US'
assert format_money(one_million_eur, locale='fr_CA') == '1 000 000,00 €'

def test_add(self):
assert (self.one_million_bucks + self.one_million_bucks ==
Money(amount='2000000', currency=self.USD))
Expand Down

0 comments on commit 907aae2

Please sign in to comment.