# HG changeset patch # User Thomas De Schampheleire # Date 2019-04-29 21:26:00 # Node ID f4b050aceb1e218c8a0f50b70463f47d5cdb96d2 # Parent 7135fd2db7c92713896f05e4e58ce0e96c7d3486 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. diff --git a/kallithea/templates/admin/permissions/permissions_globals.html b/kallithea/templates/admin/permissions/permissions_globals.html --- a/kallithea/templates/admin/permissions/permissions_globals.html +++ b/kallithea/templates/admin/permissions/permissions_globals.html @@ -7,7 +7,7 @@ ${h.form(url('admin_permissions'), metho ${h.checkbox('anonymous',True)} ${_('Allow anonymous access')} - ${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')))))} + ${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'))))}