From 3b6aebe0c5d602fab7913bdde450d87ea3ceab76 Mon Sep 17 00:00:00 2001 From: Sushil Kumar Date: Sat, 28 Dec 2013 16:22:22 +0000 Subject: [PATCH] Adds Missing _() for Exception Message Translation Reasons: - Exception messages missing underscores. This is necessary to mark messages as ready for translation, and is already the defacto standard across the trove codebase,as per, https://wiki.openstack.org/wiki/Translations - Because of incorrect Exception messages, it does not overrides the default message of BadRequest. Changes: - Adds the missing underscore function to wrap a few user-facing exception messages. Change-Id: Ib4a183f717146493e514b8169679a57cc2ecfd01 Closes-Bug: #1264688 --- trove/guestagent/datastore/mysql/service.py | 6 ++++-- trove/instance/models.py | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/trove/guestagent/datastore/mysql/service.py b/trove/guestagent/datastore/mysql/service.py index 476ac1e43c..e85c76d013 100644 --- a/trove/guestagent/datastore/mysql/service.py +++ b/trove/guestagent/datastore/mysql/service.py @@ -350,8 +350,10 @@ class MySqlAdmin(object): try: user.name = username # Could possibly throw a BadRequest here. except exceptions.ValueError as ve: - raise exception.BadRequest("Username %s is not valid: %s" - % (username, ve.message)) + raise exception.BadRequest(_("Username %(user)s is not valid" + ": %(reason)s") % + {'user': username, 'reason': ve.message} + ) with LocalSqlClient(get_engine()) as client: q = sql_query.Query() q.columns = ['User', 'Host', 'Password'] diff --git a/trove/instance/models.py b/trove/instance/models.py index 30127ff3a2..05e4a93042 100644 --- a/trove/instance/models.py +++ b/trove/instance/models.py @@ -560,13 +560,13 @@ class Instance(BuiltInstance): self.validate_can_perform_action() LOG.info("Resizing volume of instance %s..." % self.id) if not self.volume_size: - raise exception.BadRequest("Instance %s has no volume." + raise exception.BadRequest(_("Instance %s has no volume.") % self.id) old_size = self.volume_size if int(new_size) <= old_size: - msg = ("The new volume 'size' must be larger than the current " - "volume size of '%s'") - raise exception.BadRequest(msg % old_size) + raise exception.BadRequest(_("The new volume 'size' must be " + "larger than the current volume " + "size of '%s'") % old_size) # Set the task to Resizing before sending off to the taskmanager self.update_db(task_status=InstanceTasks.RESIZING) task_api.API(self.context).resize_volume(new_size, self.id)