def test_renders_prices_with_correct_currency(self): assert_equals(u'1.024,00 €', self.generator.format_price(1024)) self.generator.invoice.currency = 'USD' self.generator.format = Format(locale='en') assert_equals('en', str(self.generator.format.locale)) assert_equals(u'$1,024.00', self.generator.format_price(1024))
def __new__(cls, component, name, env=None): self = str.__new__(cls, name) self.component = component self.translations = component.translations[name] self.format = Format(name) self.locale = Locale(name) self._env = env return self
def _get_format(): lang = translation.get_language() try: locale = Locale(translation.to_locale(lang)) except UnknownLocaleError: locale = Locale( translation.to_locale(settings.BABEL_FALLBACK.get(lang, 'en-US'))) return Format(locale)
def __new__(cls, name, root, translations_dir, categories=[]): self = str.__new__(cls, name) self.format = Format(name) self.timezone = timezone('Europe/Moscow') self.root = getattr(root, name) self._translations = get_translations(translations_dir, self, categories) return self
def __init__(self, invoice): self.invoice = invoice self.invoice_datetime = ConfigStore.parse_date( self.invoice.invoice_date) self.config = ConfigStore.get_configuration(when=self.invoice_datetime) self.translation = Translations.load('locale', locales=[self.invoice.language], domain='pyinvoice') self.ugettext = self.translation.ugettext self.format = Format(locale=self.invoice.language)
def _format_decimal(num, format=None): """Returns the string of a number formatted for the current language. Uses django's translation.get_language() to find the current language from the request. Falls back to the default language if babel does not support the current. """ lang = translation.get_language() if not localedata.exists(lang): lang = settings.LANGUAGE_CODE locale = Locale(translation.to_locale(lang)) return Format(locale).decimal(num, format)
def _get_format(): lang = get_language() return Format(utils.get_locale_from_lang(lang))
def _get_format(): lang = translation.get_language() locale = Locale(translation.to_locale(lang)) return Format(locale)
def _get_format(): lang = translation.get_language() return Format(get_locale_from_lang(lang))