diff options
| author | Tang Chen <chen.tang@easystack.cn> | 2016-05-14 15:12:57 +0800 |
|---|---|---|
| committer | Tang Chen <chen.tang@easystack.cn> | 2016-05-24 11:03:49 +0800 |
| commit | 5398c96e2a816148cbcde7ce43c46de6721051f6 (patch) | |
| tree | a0d791665b99f28293f1fdc3f2830a3259461745 /openstackclient/compute/v2/usage.py | |
| parent | e3f169280c665c62b6e3708c1ae3b763ab91a174 (diff) | |
| download | python-openstackclient-5398c96e2a816148cbcde7ce43c46de6721051f6.tar.gz | |
Fix i18n support for help and error messages in compute
Change-Id: Id6eebcb48d1b7b49b6636524506294edbc44a83f
Partial-bug: #1574965
Diffstat (limited to 'openstackclient/compute/v2/usage.py')
| -rw-r--r-- | openstackclient/compute/v2/usage.py | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/openstackclient/compute/v2/usage.py b/openstackclient/compute/v2/usage.py index baa50170..b83bef13 100644 --- a/openstackclient/compute/v2/usage.py +++ b/openstackclient/compute/v2/usage.py @@ -22,6 +22,7 @@ import six from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class ListUsage(command.Lister): @@ -33,14 +34,14 @@ class ListUsage(command.Lister): "--start", metavar="<start>", default=None, - help="Usage range start date, ex 2012-01-20" - " (default: 4 weeks ago)" + help=_("Usage range start date, ex 2012-01-20" + " (default: 4 weeks ago)") ) parser.add_argument( "--end", metavar="<end>", default=None, - help="Usage range end date, ex 2012-01-20 (default: tomorrow)" + help=_("Usage range end date, ex 2012-01-20 (default: tomorrow)") ) return parser @@ -95,10 +96,10 @@ class ListUsage(command.Lister): pass if parsed_args.formatter == 'table' and len(usage_list) > 0: - sys.stdout.write("Usage from %s to %s: \n" % ( - start.strftime(dateformat), - end.strftime(dateformat), - )) + sys.stdout.write(_("Usage from %(start)s to %(end)s: \n") % { + "start": start.strftime(dateformat), + "end": end.strftime(dateformat), + }) return (column_headers, (utils.get_item_properties( @@ -122,20 +123,20 @@ class ShowUsage(command.ShowOne): "--project", metavar="<project>", default=None, - help="Name or ID of project to show usage for" + help=_("Name or ID of project to show usage for") ) parser.add_argument( "--start", metavar="<start>", default=None, - help="Usage range start date, ex 2012-01-20" - " (default: 4 weeks ago)" + help=_("Usage range start date, ex 2012-01-20" + " (default: 4 weeks ago)") ) parser.add_argument( "--end", metavar="<end>", default=None, - help="Usage range end date, ex 2012-01-20 (default: tomorrow)" + help=_("Usage range end date, ex 2012-01-20 (default: tomorrow)") ) return parser @@ -167,11 +168,12 @@ class ShowUsage(command.ShowOne): usage = compute_client.usage.get(project, start, end) if parsed_args.formatter == 'table': - sys.stdout.write("Usage from %s to %s on project %s: \n" % ( - start.strftime(dateformat), - end.strftime(dateformat), - project - )) + sys.stdout.write(_("Usage from %(start)s to %(end)s on " + "project %(project)s: \n") % { + "start": start.strftime(dateformat), + "end": end.strftime(dateformat), + "project": project, + }) info = {} info['Servers'] = ( |
