Roundup Tracker - Issues

Issue 2551146

classification
Generating locale info reports errors with misformatted strings
Type: behavior Severity: normal
Components: User Interface Versions:
process
Status: new
:
: : rouilj
Priority: : StarterTicket

Created on 2021-07-03 16:51 by rouilj, last changed 2021-08-21 19:19 by rouilj.

Messages
msg7297 Author: [hidden] (rouilj) Date: 2021-07-03 16:51
When running step 1 of Release.txt, we get abunch of warnings like:

../roundup/cgi/client.py:1430: warning: 'msgid' format string with 
unnamed arguments cannot be properly localized:
                      The translator cannot reorder the arguments.
                      Please consider using a format string with named 
arguments,
                      and a mapping instead of a tuple for the 
arguments.
 
which points to:

  logger.error(
     self._("Csrf mismatch user: current session %s != stored session 
%s, current user/stored user is: %s for key %s."),
        current_session, nonce_session, current_user, key)

It makes it easier for translators if written as:

     self._("Csrf mismatch user: current session %(current_session)s != 
stored session %(nonce_session)s, current user/stored user is: %
(current_user)s for key %(key)s."),
        {"current_session": current_session,
         "nonce_session": nonce_session,
         "current_user": current_user, "key": key})

or, if the arguments are simple variables in local scope
(as opposed to function calls etc.)

     self._("Csrf mismatch user: current session %(current_session)s != 
stored session %(nonce_session)s, current user/stored user is: %
(current_user)s for key %(key)s."), locals())

Most important for translation are user facing strings. Second most 
important are admin facing (which includes logging at warning or 
higher.) Third are tracing statements at info or lower.
History
Date User Action Args
2021-08-21 19:19:33rouiljsetkeywords: + StarterTicket
2021-07-03 16:51:12rouiljcreate