Skip to content

Commit 53e05e7

Browse files
committed
i18n support for help and error messages in cinder
Change-Id: I98fbc959034fe0530966291643b381855801de20
1 parent 17bc850 commit 53e05e7

13 files changed

Lines changed: 257 additions & 223 deletions

File tree

openstackclient/volume/client.py

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

1818
from openstackclient.common import utils
19+
from openstackclient.i18n import _
1920

2021
LOG = logging.getLogger(__name__)
2122

@@ -73,7 +74,7 @@ def build_option_parser(parser):
7374
'--os-volume-api-version',
7475
metavar='<volume-api-version>',
7576
default=utils.env('OS_VOLUME_API_VERSION'),
76-
help='Volume API version, default=' +
77-
DEFAULT_API_VERSION +
78-
' (Env: OS_VOLUME_API_VERSION)')
77+
help=_('Volume API version, default=%s '
78+
'(Env: OS_VOLUME_API_VERSION)') % DEFAULT_API_VERSION
79+
)
7980
return parser

openstackclient/volume/v1/backup.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from openstackclient.common import command
2222
from openstackclient.common import utils
23+
from openstackclient.i18n import _
2324

2425

2526
class CreateBackup(command.ShowOne):
@@ -30,23 +31,23 @@ def get_parser(self, prog_name):
3031
parser.add_argument(
3132
'volume',
3233
metavar='<volume>',
33-
help='Volume to backup (name or ID)',
34+
help=_('Volume to backup (name or ID)'),
3435
)
3536
parser.add_argument(
3637
'--container',
3738
metavar='<container>',
3839
required=False,
39-
help='Optional backup container name',
40+
help=_('Optional backup container name'),
4041
)
4142
parser.add_argument(
4243
'--name',
4344
metavar='<name>',
44-
help='Name of the backup',
45+
help=_('Name of the backup'),
4546
)
4647
parser.add_argument(
4748
'--description',
4849
metavar='<description>',
49-
help='Description of the backup',
50+
help=_('Description of the backup'),
5051
)
5152
return parser
5253

@@ -74,7 +75,7 @@ def get_parser(self, prog_name):
7475
'backups',
7576
metavar='<backup>',
7677
nargs="+",
77-
help='Backup(s) to delete (ID only)',
78+
help=_('Backup(s) to delete (ID only)'),
7879
)
7980
return parser
8081

@@ -95,7 +96,7 @@ def get_parser(self, prog_name):
9596
'--long',
9697
action='store_true',
9798
default=False,
98-
help='List additional fields in output',
99+
help=_('List additional fields in output'),
99100
)
100101
return parser
101102

@@ -148,11 +149,13 @@ def get_parser(self, prog_name):
148149
parser.add_argument(
149150
'backup',
150151
metavar='<backup>',
151-
help='Backup to restore (ID only)')
152+
help=_('Backup to restore (ID only)')
153+
)
152154
parser.add_argument(
153155
'volume',
154156
metavar='<volume>',
155-
help='Volume to restore to (name or ID)')
157+
help=_('Volume to restore to (name or ID)')
158+
)
156159
return parser
157160

158161
def take_action(self, parsed_args):
@@ -173,7 +176,8 @@ def get_parser(self, prog_name):
173176
parser.add_argument(
174177
'backup',
175178
metavar='<backup>',
176-
help='Backup to display (ID only)')
179+
help=_('Backup to display (ID only)')
180+
)
177181
return parser
178182

179183
def take_action(self, parsed_args):

openstackclient/volume/v1/qos_specs.py

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from openstackclient.common import command
2121
from openstackclient.common import parseractions
2222
from openstackclient.common import utils
23+
from openstackclient.i18n import _
2324

2425

2526
class AssociateQos(command.Command):
@@ -30,12 +31,12 @@ def get_parser(self, prog_name):
3031
parser.add_argument(
3132
'qos_spec',
3233
metavar='<qos-spec>',
33-
help='QoS specification to modify (name or ID)',
34+
help=_('QoS specification to modify (name or ID)'),
3435
)
3536
parser.add_argument(
3637
'volume_type',
3738
metavar='<volume-type>',
38-
help='Volume type to associate the QoS (name or ID)',
39+
help=_('Volume type to associate the QoS (name or ID)'),
3940
)
4041
return parser
4142

@@ -57,23 +58,24 @@ def get_parser(self, prog_name):
5758
parser.add_argument(
5859
'name',
5960
metavar='<name>',
60-
help='New QoS specification name',
61+
help=_('New QoS specification name'),
6162
)
6263
consumer_choices = ['front-end', 'back-end', 'both']
6364
parser.add_argument(
6465
'--consumer',
6566
metavar='<consumer>',
6667
choices=consumer_choices,
6768
default='both',
68-
help='Consumer of the QoS. Valid consumers: %s '
69-
"(defaults to 'both')" % utils.format_list(consumer_choices)
69+
help=(_('Consumer of the QoS. Valid consumers: %s '
70+
"(defaults to 'both')") %
71+
utils.format_list(consumer_choices))
7072
)
7173
parser.add_argument(
7274
'--property',
7375
metavar='<key=value>',
7476
action=parseractions.KeyValueAction,
75-
help='Set a QoS specification property '
76-
'(repeat option to set multiple properties)',
77+
help=_('Set a QoS specification property '
78+
'(repeat option to set multiple properties)'),
7779
)
7880
return parser
7981

@@ -99,7 +101,7 @@ def get_parser(self, prog_name):
99101
'qos_specs',
100102
metavar='<qos-spec>',
101103
nargs="+",
102-
help='QoS specification(s) to delete (name or ID)',
104+
help=_('QoS specification(s) to delete (name or ID)'),
103105
)
104106
return parser
105107

@@ -118,19 +120,19 @@ def get_parser(self, prog_name):
118120
parser.add_argument(
119121
'qos_spec',
120122
metavar='<qos-spec>',
121-
help='QoS specification to modify (name or ID)',
123+
help=_('QoS specification to modify (name or ID)'),
122124
)
123125
volume_type_group = parser.add_mutually_exclusive_group()
124126
volume_type_group.add_argument(
125127
'--volume-type',
126128
metavar='<volume-type>',
127-
help='Volume type to disassociate the QoS from (name or ID)',
129+
help=_('Volume type to disassociate the QoS from (name or ID)'),
128130
)
129131
volume_type_group.add_argument(
130132
'--all',
131133
action='store_true',
132134
default=False,
133-
help='Disassociate the QoS from every volume type',
135+
help=_('Disassociate the QoS from every volume type'),
134136
)
135137

136138
return parser
@@ -181,14 +183,14 @@ def get_parser(self, prog_name):
181183
parser.add_argument(
182184
'qos_spec',
183185
metavar='<qos-spec>',
184-
help='QoS specification to modify (name or ID)',
186+
help=_('QoS specification to modify (name or ID)'),
185187
)
186188
parser.add_argument(
187189
'--property',
188190
metavar='<key=value>',
189191
action=parseractions.KeyValueAction,
190-
help='Property to add or modify for this QoS specification '
191-
'(repeat option to set multiple properties)',
192+
help=_('Property to add or modify for this QoS specification '
193+
'(repeat option to set multiple properties)'),
192194
)
193195
return parser
194196

@@ -201,7 +203,7 @@ def take_action(self, parsed_args):
201203
volume_client.qos_specs.set_keys(qos_spec.id,
202204
parsed_args.property)
203205
else:
204-
self.app.log.error("No changes requested\n")
206+
self.app.log.error(_("No changes requested\n"))
205207

206208

207209
class ShowQos(command.ShowOne):
@@ -212,7 +214,7 @@ def get_parser(self, prog_name):
212214
parser.add_argument(
213215
'qos_spec',
214216
metavar='<qos-spec>',
215-
help='QoS specification to display (name or ID)',
217+
help=_('QoS specification to display (name or ID)'),
216218
)
217219
return parser
218220

@@ -241,15 +243,15 @@ def get_parser(self, prog_name):
241243
parser.add_argument(
242244
'qos_spec',
243245
metavar='<qos-spec>',
244-
help='QoS specification to modify (name or ID)',
246+
help=_('QoS specification to modify (name or ID)'),
245247
)
246248
parser.add_argument(
247249
'--property',
248250
metavar='<key>',
249251
action='append',
250252
default=[],
251-
help='Property to remove from the QoS specification. '
252-
'(repeat option to unset multiple properties)',
253+
help=_('Property to remove from the QoS specification. '
254+
'(repeat option to unset multiple properties)'),
253255
)
254256
return parser
255257

@@ -262,4 +264,4 @@ def take_action(self, parsed_args):
262264
volume_client.qos_specs.unset_keys(qos_spec.id,
263265
parsed_args.property)
264266
else:
265-
self.app.log.error("No changes requested\n")
267+
self.app.log.error(_("No changes requested\n"))

openstackclient/volume/v1/service.py

Lines changed: 6 additions & 3 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 utils
19+
from openstackclient.i18n import _
1920

2021

2122
class ListService(command.Lister):
@@ -26,16 +27,18 @@ def get_parser(self, prog_name):
2627
parser.add_argument(
2728
"--host",
2829
metavar="<host>",
29-
help="List services on specified host (name only)")
30+
help=_("List services on specified host (name only)")
31+
)
3032
parser.add_argument(
3133
"--service",
3234
metavar="<service>",
33-
help="List only specified service (name only)")
35+
help=_("List only specified service (name only)")
36+
)
3437
parser.add_argument(
3538
"--long",
3639
action="store_true",
3740
default=False,
38-
help="List additional fields in output"
41+
help=_("List additional fields in output")
3942
)
4043
return parser
4144

0 commit comments

Comments
 (0)