Mercurial > kallithea
changeset 7644:f4b050aceb1e stable
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.
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Mon, 29 Apr 2019 21:26:00 +0200 |
parents | 7135fd2db7c9 |
children | e0626084e9c5 |
files | kallithea/templates/admin/permissions/permissions_globals.html |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/templates/admin/permissions/permissions_globals.html Tue Apr 30 19:03:02 2019 +0200 +++ b/kallithea/templates/admin/permissions/permissions_globals.html Mon Apr 29 21:26:00 2019 +0200 @@ -7,7 +7,7 @@ ${h.checkbox('anonymous',True)} <span>${_('Allow anonymous access')}</span> </label> - <span class="help-block">${h.literal(_('Allow access to Kallithea without needing to log in. Anonymous users use %s user permissions.' % (h.link_to('*default*',h.url('admin_permissions_perms')))))}</span> + <span class="help-block">${h.literal(_('Allow access to Kallithea without needing to log in. Anonymous users use %s user permissions.') % (h.link_to('*default*',h.url('admin_permissions_perms'))))}</span> </div> </div> <div class="form-group">