i18n issues on "Delete" buttons

Bug #1005056 reported by You Yamagata
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Medium
Gabriel Hurley

Bug Description

Delete buttons (ex. "Delete Flavor", "Delete Flavors" in Flavors view) can't be localized correctly because "action" word and "data_type" word are concatenated in BatchAction. _conjugate().

Concatenation has two problems. One is that the words order is fixed and others is that l10n workers want to change the sentence overall to keep layout sometimes. (some words is too long after translation)
I guess that CreateFlavor class which uses "verbose_name = _("Create Flavor")" may be good way for i18n.

So I made a patch as trial. But I am not familiar with horizon. There may be another issues potentially.

--- a/horizon/dashboards/syspanel/flavors/tables.py
+++ b/horizon/dashboards/syspanel/flavors/tables.py
@@ -12,6 +12,11 @@ LOG = logging.getLogger(__name__)
 class DeleteFlavor(tables.DeleteAction):
     data_type_singular = _("Flavor")
     data_type_plural = _("Flavors")
+ verbose_name = _("Delete Flavor")
+ verbose_name_plural = _("Delete Flavors")
+
+ def update(self, request, datum):
+ pass

Revision history for this message
Gabriel Hurley (gabriel-hurley) wrote :

Definitely worth finding a fix for. We'll have to see what the best options are here.

Changed in horizon:
assignee: nobody → Gabriel Hurley (gabriel-hurley)
importance: Undecided → Medium
milestone: none → folsom-2
status: New → Confirmed
Changed in horizon:
status: Confirmed → In Progress
Revision history for this message
Gabriel Hurley (gabriel-hurley) wrote :

I think it's still possible to do this programmatically if the strings are computed at class construction time instead of at runtime... but that's a more in-depth investigation. I'll bump this to F3 to finish the work on it.

Changed in horizon:
milestone: folsom-2 → folsom-3
Revision history for this message
Akihiro Motoki (amotoki) wrote :

Hi Gabriel,

I would like to know the status of this bug. It is important for I18N.

The following patch is a very simple approach which does not change the current behavior.
This allow translators to changes the word order.

On the other hand, it is important the point the original reporter You Yamagata pointed.
From the point of translation view too short sentence such as one word is too general.
I think that one phrase needs to have at least two word to keep translations well.

Thanks,

diff --git a/horizon/tables/actions.py b/horizon/tables/actions.py
index f5d7b9f..a243a76 100644
--- a/horizon/tables/actions.py
+++ b/horizon/tables/actions.py
@@ -464,7 +464,8 @@ class BatchAction(Action):
             data_type = self.data_type_singular
         else:
             data_type = self.data_type_plural
- return string_concat(action, ' ', data_type)
+ return _("%(action)s %(data_type)s") % {'action': action,
+ 'data_type': data_type}

     def action(self, request, datum_id):
         """

Revision history for this message
Gabriel Hurley (gabriel-hurley) wrote :

That's a great suggestion. Sorry it took me so long to get back to this. I'm gonna go see about implementing that right now.

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/11384

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

Reviewed: https://review.openstack.org/11384
Committed: http://github.com/openstack/horizon/commit/ed086645c6a75d4ddaca1fb67d7d13cfbd3d1c55
Submitter: Jenkins
Branch: master

commit ed086645c6a75d4ddaca1fb67d7d13cfbd3d1c55
Author: Gabriel Hurley <email address hidden>
Date: Tue Aug 14 18:45:29 2012 -0700

    Resolves i18n problem on batch actions.

    Updated translation files along with it. Thanks to amotoki
    for the fix.

    Fixes bug 1005056.

    Change-Id: Ia339a5f9e45d1d4275af5b776c296b05ddfe6e8d

Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: folsom-3 → 2012.2
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.