Skip to content

Commit 5a3a786

Browse files
author
Tang Chen
committed
Trivial: Fix i18n support in network/common.py
Some missing i18n problems in network. Change-Id: I45a09a6ada1aad5a64256c0d0a0a2b6e250df670
1 parent ca58ab9 commit 5a3a786

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

openstackclient/network/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from openstack import profile
1818

1919
from openstackclient.common import utils
20+
from openstackclient.i18n import _
2021

2122

2223
LOG = logging.getLogger(__name__)
@@ -51,7 +52,7 @@ def build_option_parser(parser):
5152
'--os-network-api-version',
5253
metavar='<network-api-version>',
5354
default=utils.env('OS_NETWORK_API_VERSION'),
54-
help='Network API version, default=' +
55-
DEFAULT_API_VERSION +
56-
' (Env: OS_NETWORK_API_VERSION)')
55+
help=_("Network API version, default=%s "
56+
"(Env: OS_NETWORK_API_VERSION)") % DEFAULT_API_VERSION
57+
)
5758
return parser

openstackclient/network/common.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from openstackclient.common import command
1818
from openstackclient.common import exceptions
19+
from openstackclient.i18n import _
1920

2021

2122
@six.add_metaclass(abc.ABCMeta)
@@ -94,14 +95,22 @@ def take_action(self, parsed_args):
9495
self.take_action_compute(self.app.client_manager.compute,
9596
parsed_args)
9697
except Exception as e:
97-
self.app.log.error("Failed to delete %s with name or ID "
98-
"'%s': %s" % (self.resource, r, e))
98+
msg = _("Failed to delete %(resource)s with name or ID "
99+
"'%(name_or_id)s': %(e)s") % {
100+
"resource": self.resource,
101+
"name_or_id": r,
102+
"e": e,
103+
}
104+
self.app.log.error(msg)
99105
ret += 1
100106

101107
if ret:
102108
total = len(resources)
103-
msg = "%s of %s %ss failed to delete." % (ret, total,
104-
self.resource)
109+
msg = _("%(num)s of %(total)s %(resource)s failed to delete.") % {
110+
"num": ret,
111+
"total": total,
112+
"resource": self.resource,
113+
}
105114
raise exceptions.CommandError(msg)
106115

107116

0 commit comments

Comments
 (0)