Changeset - f4b050aceb1e
[Not reviewed]
stable
0 1 0
Thomas De Schampheleire - 7 years ago 2019-04-29 21:26:00
thomas.de_schampheleire@nokia.com
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 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/templates/admin/permissions/permissions_globals.html
Show inline comments
 
@@ -7,7 +7,7 @@ ${h.form(url('admin_permissions'), metho
 
                        ${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">
0 comments (0 inline, 0 general)