def test_locale_selector(app): """Test locale selector.""" app.config['I18N_LANGUAGES'] = ['da'] InvenioI18N(app) with app.test_request_context(headers=[('Accept-Language', 'da')]): assert str(get_locale()) == 'da' assert format_number(10.1) == '10,1' assert gettext('Translate') == u'Oversætte' with app.test_request_context(headers=[('Accept-Language', 'en')]): assert str(get_locale()) == 'en' assert format_number(10.1) == '10.1' assert gettext('Translate') == 'Translate'
def test_locale_selector(app): """Test locale selector.""" app.config['I18N_LANGUAGES'] = [('da', 'Danish')] InvenioI18N(app) with app.test_request_context(headers=[('Accept-Language', 'da')]): assert str(get_locale()) == 'da' assert format_number(10.1) == '10,1' assert gettext('Translate') == u'Oversætte' with app.test_request_context(headers=[('Accept-Language', 'en')]): assert str(get_locale()) == 'en' assert format_number(10.1) == '10.1' assert gettext('Translate') == 'Translate'
def test_locale_selector(app): """Test locale selector.""" app.config["I18N_LANGUAGES"] = [("da", "Danish")] InvenioI18N(app) with app.test_request_context(headers=[("Accept-Language", "da")]): assert str(get_locale()) == "da" assert format_number(10.1) == "10,1" assert gettext("Translate") == u"Oversætte" with app.test_request_context(headers=[("Accept-Language", "en")]): assert str(get_locale()) == "en" assert format_number(10.1) == "10.1" assert gettext("Translate") == "Translate"
def test_locale_selector(app): """Test locale selector.""" app.config.update( I18N_LANGUAGES=[('da', 'Danish')], I18N_TRANSLATIONS_PATHS=[join(dirname(__file__), 'translations')], ) i18n = InvenioI18N(app) with app.test_request_context(headers=[('Accept-Language', 'da')]): assert str(get_locale()) == 'da' assert format_number(10.1) == '10,1' assert gettext('Translate') == u'Oversætte' with app.test_request_context(headers=[('Accept-Language', 'en')]): assert str(get_locale()) == 'en' assert format_number(10.1) == '10.1' assert gettext('Translate') == 'From test catalog'
def test_locale_selector(app): """Test locale selector.""" app.config.update( I18N_LANGUAGES=[("da", "Danish")], I18N_TRANSLATIONS_PATHS=[join(dirname(__file__), "translations")], ) i18n = InvenioI18N(app) with app.test_request_context(headers=[("Accept-Language", "da")]): assert str(get_locale()) == "da" assert format_number(10.1) == "10,1" assert gettext("Translate") == "Oversætte" with app.test_request_context(headers=[("Accept-Language", "en")]): assert str(get_locale()) == "en" assert format_number(10.1) == "10.1" assert gettext("Translate") == "From test catalog"
def test_basics(self): app = flask.Flask(__name__) b = babel.Babel(app) n = 1099 with app.test_request_context(): assert babel.format_number(n) == u'1,099' assert babel.format_decimal(Decimal('1010.99')) == u'1,010.99' assert babel.format_currency(n, 'USD') == '$1,099.00' assert babel.format_percent(0.19) == '19%' assert babel.format_scientific(10000) == u'1E4'