Any message with more than one variable should use named interpolation instead of positional

Bug #1592300 reported by zhang.xiuhua
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
zhang.xiuhua

Bug Description

Any message with more than one variable should use named interpolation instead of positional, to allow translators to move the variables around in the string to account for differences in grammar and writing direction.

For example, do not do this:

# WRONG
raise ValueError(_('some message: v1=%s v2=%s') % (v1, v2))
Instead, use this style:

# RIGHT
raise ValueError(_('some message: v1=%(v1)s v2=%(v2)s') % {'v1': v1, 'v2': v2})

Refer to this document:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html

Changed in horizon:
assignee: nobody → zhang.xiuhua (zhang-xiuhua)
status: New → In Progress
Revision history for this message
Cindy Lu (clu-m) wrote :
Changed in horizon:
assignee: zhang.xiuhua (zhang-xiuhua) → David Lyle (david-lyle)
Revision history for this message
David Lyle (david-lyle) wrote :

I'm dubious of the benefits of changing existing code to accommodate new external recommendations. It's not even necessary for python v3 compatibility. I view responding to changing external guidelines in the light of:
1) does this fix broken behavior
2) does this provide a marked improvement over the existing code?
3) is this required for future changes?

This seems to meet none of those. I will approve the first patch, but I really don't want to see a long string of related patches. Or, I would prefer one blanket patch to cover all cases at once.

Changed in horizon:
assignee: David Lyle (david-lyle) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/328902
Committed: https://git.openstack.org/cgit/openstack/horizon/commit/?id=e6c7c3364191b69266f5bae762f4abbb8161dc76
Submitter: Jenkins
Branch: master

commit e6c7c3364191b69266f5bae762f4abbb8161dc76
Author: zhang.xiuhua <zhang.xiuhua@99cloud.net>
Date: Mon Jun 13 16:39:17 2016 +0800

    Modify warning message

    refer to this link:
    http://docs.openstack.org/developer/oslo.i18n/guidelines.html

    Partial-bug: #1592300

    Change-Id: I655628bf5e23dbc66a6ecd4dedba0c7abc5e2100

Changed in horizon:
assignee: nobody → zhang.xiuhua (zhang-xiuhua)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

Fix proposed to branch: master
Review: https://review.openstack.org/331510

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on horizon (master)

Change abandoned by zhang.xiuhua (zhang.xiuhua@99cloud.net) on branch: master
Review: https://review.openstack.org/329774
Reason: abandon it

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by zhang.xiuhua (zhang.xiuhua@99cloud.net) on branch: master
Review: https://review.openstack.org/331510
Reason: abandon

Changed in horizon:
importance: Undecided → Low
milestone: none → ocata-1
Changed in horizon:
milestone: ocata-1 → ocata-2
Revision history for this message
Rob Cresswell (robcresswell-deactivatedaccount) wrote :

Looks like all changes were merged, so marking as Fix Released.

Changed in horizon:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.