|
12 | 12 | import flask |
13 | 13 | from datetime import datetime, timedelta |
14 | 14 | import flask_babel as babel |
15 | | -from flask_babel import gettext, ngettext, lazy_gettext, get_translations |
| 15 | +from flask_babel import gettext, ngettext, lazy_gettext, lazy_ngettext, get_translations |
16 | 16 | from babel.support import NullTranslations |
17 | 17 | from flask_babel._compat import text_type |
18 | 18 |
|
@@ -266,6 +266,18 @@ def test_lazy_gettext(self): |
266 | 266 | assert text_type(yes) == 'Yes' |
267 | 267 | assert yes.__html__() == 'Yes' |
268 | 268 |
|
| 269 | + def test_lazy_ngettext(self): |
| 270 | + app = flask.Flask(__name__) |
| 271 | + babel.Babel(app, default_locale='de_DE') |
| 272 | + one_apple = lazy_ngettext(u'%(num)s Apple', u'%(num)s Apples', 1) |
| 273 | + with app.test_request_context(): |
| 274 | + assert text_type(one_apple) == '1 Apfel' |
| 275 | + assert one_apple.__html__() == '1 Apfel' |
| 276 | + two_apples = lazy_ngettext(u'%(num)s Apple', u'%(num)s Apples', 2) |
| 277 | + with app.test_request_context(): |
| 278 | + assert text_type(two_apples) == u'2 Äpfel' |
| 279 | + assert two_apples.__html__() == u'2 Äpfel' |
| 280 | + |
269 | 281 | def test_list_translations(self): |
270 | 282 | app = flask.Flask(__name__) |
271 | 283 | b = babel.Babel(app, default_locale='de_DE') |
|
0 commit comments