Files @ f4b050aceb1e
Branch filter:

Location: kallithea/pytest.ini

Thomas De Schampheleire
templates: don't apply formatting inside ugettext (_) calls

The call to ugettext (_) is there to obtain a translated string. It may
contain format specifiers like '%s'. If the code is as follows:

_('User-facing string with %s data' % data)

then the string will never be translated in the application, because the
variable 'data' is replaced in the string _before_ being passed to the
translation function '_' (ugettext).

The correct code is:

_('User-facing string with %s data') % data

so that we first get the translated string and _then_ substitute the
variable 'data'.

Note: the string extraction logic (used to extract all user-facing strings
to pass to translators) happily accepted the bad code, ignoring the string
substitution. It would have been better if it had warned loudly about this
problem.
1
2
3
4
5
6
7
8
9
[pytest]
# only look for tests in kallithea/tests
python_files = kallithea/tests/**/test_*.py
addopts =
    # --verbose
    # show extra test summary info as specified by chars (f)ailed, (E)error, (s)skipped, (x)failed, (X)passed, (w)warnings.
    -rfEsxXw
    # Shorter scrollbacks; less stuff to scroll through
    --tb=short