| 573 | assert tmpl.render(apples=5, LANGUAGE="de") == "5 Äpfel" |
| 574 | |
| 575 | def test_num_called_num(self): |
| 576 | source = newstyle_i18n_env.compile( |
| 577 | """ |
| 578 | {% trans num=3 %}{{ num }} apple{% pluralize |
| 579 | %}{{ num }} apples{% endtrans %} |
| 580 | """, |
| 581 | raw=True, |
| 582 | ) |
| 583 | # quite hacky, but the only way to properly test that. The idea is |
| 584 | # that the generated code does not pass num twice (although that |
| 585 | # would work) for better performance. This only works on the |
| 586 | # newstyle gettext of course |
| 587 | assert ( |
| 588 | re.search(r"u?'%\(num\)s apple', u?'%\(num\)s apples', 3", source) |
| 589 | is not None |
| 590 | ) |
| 591 | |
| 592 | def test_trans_vars(self): |
| 593 | t1 = newstyle_i18n_env.get_template("transvars1.html") |