Esempio n. 1
0
def test_get_currency_unit_pattern():
    assert get_currency_unit_pattern('USD', locale='en_US') == '{0} {1}'
    assert get_currency_unit_pattern('USD', locale='es_GT') == '{1} {0}'

    # 'ro' locale various pattern according to count
    assert get_currency_unit_pattern('USD', locale='ro', count=1) == '{0} {1}'
    assert get_currency_unit_pattern('USD', locale='ro', count=2) == '{0} {1}'
    assert get_currency_unit_pattern('USD', locale='ro', count=100) == '{0} de {1}'
    assert get_currency_unit_pattern('USD', locale='ro') == '{0} de {1}'
Esempio n. 2
0
def test_get_currency_unit_pattern():
    assert get_currency_unit_pattern('USD', locale='en_US') == '{0} {1}'
    assert get_currency_unit_pattern('USD', locale='es_GT') == '{1} {0}'

    # 'ro' locale various pattern according to count
    assert get_currency_unit_pattern('USD', locale='ro', count=1) == '{0} {1}'
    assert get_currency_unit_pattern('USD', locale='ro', count=2) == '{0} {1}'
    assert get_currency_unit_pattern('USD', locale='ro', count=100) == '{0} de {1}'
    assert get_currency_unit_pattern('USD', locale='ro') == '{0} de {1}'
Esempio n. 3
0
    def _format_currency_long_name(self, locale):
        # This reproduces some of bable.numbers._format_currency_long_name
        # Step 3.
        unit_pattern = get_currency_unit_pattern(self.options.currency,
                                                 count=self,
                                                 locale=locale)

        # Step 4.
        display_name = get_currency_name(self.options.currency,
                                         count=self,
                                         locale=locale)

        # Step 5.
        base_pattern = locale.decimal_formats.get(None)
        pattern = self._apply_options(base_pattern)

        number_part = pattern.apply(
            self,
            locale,
            currency=self.options.currency,
        )
        return unit_pattern.format(number_part, display_name)