diff --git a/horizon/tables/actions.py b/horizon/tables/actions.py index fda32de06..d841e905e 100644 --- a/horizon/tables/actions.py +++ b/horizon/tables/actions.py @@ -954,13 +954,26 @@ class DeleteAction(BatchAction): class UpdateAction(object): """A table action for cell updates by inline editing.""" name = "update" - action_present = _("Update") - action_past = _("Updated") - data_type_singular = "update" def action(self, request, datum, obj_id, cell_name, new_cell_value): self.update_cell(request, datum, obj_id, cell_name, new_cell_value) + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Update Item", + u"Update Items", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Updated Item", + u"Updated Items", + count + ) + def update_cell(self, request, datum, obj_id, cell_name, new_cell_value): """Method for saving data of the cell. diff --git a/horizon/test/tests/tables.py b/horizon/test/tests/tables.py index ba16c7047..80eae7325 100644 --- a/horizon/test/tests/tables.py +++ b/horizon/test/tests/tables.py @@ -20,6 +20,7 @@ from django import forms from django import http from django import shortcuts from django.template import defaultfilters +from django.utils.translation import ungettext_lazy from mox3.mox import IsA # noqa import six @@ -128,28 +129,72 @@ class MyRow(tables.Row): class MyBatchAction(tables.BatchAction): name = "batch" - action_present = "Batch" - action_past = "Batched" - data_type_singular = "Item" - data_type_plural = "Items" def action(self, request, object_ids): pass + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Batch Item", + u"Batch Items", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Batched Item", + u"Batched Items", + count + ) + class MyBatchActionWithHelpText(MyBatchAction): name = "batch_help" help_text = "this is help." - action_present = "BatchHelp" - action_past = "BatchedHelp" + + @staticmethod + def action_present(count): + # No translation + return u"BatchHelp Item" + + @staticmethod + def action_past(count): + # No translation + return u"BatchedHelp Item" class MyToggleAction(tables.BatchAction): name = "toggle" - action_present = ("Down", "Up") - action_past = ("Downed", "Upped") - data_type_singular = "Item" - data_type_plural = "Items" + + def action_present(self, count): + if self.current_present_action: + return ungettext_lazy( + u"Up Item", + u"Up Items", + count + ) + else: + return ungettext_lazy( + u"Down Item", + u"Down Items", + count + ) + + def action_past(self, count): + if self.current_past_action: + return ungettext_lazy( + u"Upped Item", + u"Upped Items", + count + ) + else: + return ungettext_lazy( + u"Downed Item", + u"Downed Items", + count + ) def allowed(self, request, obj=None): if not obj: diff --git a/openstack_dashboard/dashboards/admin/volumes/volume_types/qos_specs/tables.py b/openstack_dashboard/dashboards/admin/volumes/volume_types/qos_specs/tables.py index 8ceacc862..af69763bf 100644 --- a/openstack_dashboard/dashboards/admin/volumes/volume_types/qos_specs/tables.py +++ b/openstack_dashboard/dashboards/admin/volumes/volume_types/qos_specs/tables.py @@ -12,6 +12,7 @@ from django.core.urlresolvers import reverse from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ungettext_lazy from horizon import tables @@ -32,8 +33,21 @@ class SpecCreateKeyValuePair(tables.LinkAction): class SpecDeleteKeyValuePair(tables.DeleteAction): - data_type_singular = _("Spec") - data_type_plural = _("Specs") + @staticmethod + def action_present(count): + return ungettext_lazy( + u"Delete Spec", + u"Delete Specs", + count + ) + + @staticmethod + def action_past(count): + return ungettext_lazy( + u"Deleted Spec", + u"Deleted Specs", + count + ) def delete(self, request, obj_ids): qos_spec_id = self.table.kwargs['qos_spec_id']