Several pages have concatenation in the title

Bug #1394573 reported by Doug Fish
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Undecided
Doug Fish

Bug Description

We have several panels where the add filter is used to concatenate an object to form a page title. This is problem for translation
https://wiki.openstack.org/wiki/I18n/TranslatableStrings#Use_string_formating_variables.2C_never_perform_string_concatenation

There are 16 instances in the code that can be viewed with
grep -r title=_ . | grep add:

Tags: i18n
Revision history for this message
Doug Fish (drfish) wrote :

I think this is the right pattern for fixing the problem

--- a/openstack_dashboard/dashboards/admin/volumes/templates/volumes/volumes/detail.html
+++ b/openstack_dashboard/dashboards/admin/volumes/templates/volumes/volumes/detail.html
@@ -3,7 +3,7 @@
 {% block title %}{% trans "Volume Details" %}{% endblock %}

 {% block page_header %}
- {% include "horizon/common/_page_header.html" with title=_("Volume Details: ")|add:volume.name|default:_("Volume Details:") %}
+ {% include "horizon/common/_page_header.html" with title=page_title %}
 {% endblock page_header %}

 {% block main %}
diff --git a/openstack_dashboard/dashboards/admin/volumes/volumes/views.py b/openstack_dashboard/dashboards/admin/volumes/volumes/views.py
index be19286..34145ac 100644
--- a/openstack_dashboard/dashboards/admin/volumes/volumes/views.py
+++ b/openstack_dashboard/dashboards/admin/volumes/volumes/views.py
@@ -28,6 +28,12 @@ from openstack_dashboard.dashboards.project.volumes.volumes \
 class DetailView(volumes_views.DetailView):
     template_name = "admin/volumes/volumes/detail.html"

+ def get_context_data(self, **kwargs):
+ context = super(DetailView, self).get_context_data(**kwargs)
+ volume = context["volume"]
+ context["page_title"] = _("Volume Details: %s") % volume.name
+ return context
+
     def get_redirect_url(self):
         return reverse('horizon:admin:volumes:index')

Changed in horizon:
assignee: nobody → Doug Fish (drfish)
Doug Fish (drfish)
description: updated
Doug Fish (drfish)
tags: added: i18n
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/136056

Changed in horizon:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

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

commit de20d7271aea8a3e47bd0afec2d3737035813701
Author: Doug Fish <email address hidden>
Date: Thu Nov 20 08:14:56 2014 -0600

    Create titles without concatenation

    Several panels use the template filter "add" to concatenate data
    and translatable text, for example
    title=_("Volume Details: ")|add:volume.name|default:_("Volume Details:")

    These need to be updated to use string formatting. This is needed
    because it's not clear when looking at the translations if any text
    follows the translatable segment. Dict based substitution has been
    used to further clarify the messages for translators.

    Change-Id: I54d07233d2003904468ef317c352126eb6bf5f70
    Closes-bug: #1394573

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
milestone: none → kilo-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: kilo-1 → 2015.1.0
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.