diff --git a/openstackclient/identity/v2_0/catalog.py b/openstackclient/identity/v2_0/catalog.py index 53a6fe3451..c8f48cb63f 100644 --- a/openstackclient/identity/v2_0/catalog.py +++ b/openstackclient/identity/v2_0/catalog.py @@ -89,7 +89,7 @@ class ShowCatalog(command.ShowOne): break if not data: - self.app.log.error('service %s not found\n' % + self.app.log.error(_('service %s not found\n') % parsed_args.service) return ([], []) diff --git a/openstackclient/identity/v2_0/endpoint.py b/openstackclient/identity/v2_0/endpoint.py index fcb82eb7ae..09ea738f4f 100644 --- a/openstackclient/identity/v2_0/endpoint.py +++ b/openstackclient/identity/v2_0/endpoint.py @@ -81,7 +81,8 @@ class DeleteEndpoint(command.Command): parser.add_argument( 'endpoint', metavar='', - help=_('Endpoint ID to delete')) + help=_('Endpoint ID to delete'), + ) return parser def take_action(self, parsed_args): diff --git a/openstackclient/identity/v2_0/project.py b/openstackclient/identity/v2_0/project.py index d90162c924..80f88d739f 100644 --- a/openstackclient/identity/v2_0/project.py +++ b/openstackclient/identity/v2_0/project.py @@ -88,7 +88,7 @@ class CreateProject(command.ShowOne): identity_client.tenants, parsed_args.name, ) - self.log.info('Returning existing project %s', project.name) + self.log.info(_('Returning existing project %s'), project.name) else: raise e @@ -231,7 +231,8 @@ class ShowProject(command.ShowOne): parser.add_argument( 'project', metavar='', - help=_('Project to display (name or ID)')) + help=_('Project to display (name or ID)'), + ) return parser def take_action(self, parsed_args): @@ -295,9 +296,9 @@ class UnsetProject(command.Command): metavar='', action='append', default=[], + required=True, help=_('Unset a project property ' '(repeat option to unset multiple properties)'), - required=True, ) return parser @@ -308,7 +309,7 @@ class UnsetProject(command.Command): parsed_args.project, ) if not parsed_args.property: - self.app.log.error("No changes requested\n") + self.app.log.error(_("No changes requested\n")) else: kwargs = project._info for key in parsed_args.property: diff --git a/openstackclient/identity/v2_0/role.py b/openstackclient/identity/v2_0/role.py index 1fcee15f3a..6b014d8651 100644 --- a/openstackclient/identity/v2_0/role.py +++ b/openstackclient/identity/v2_0/role.py @@ -95,7 +95,7 @@ class CreateRole(command.ShowOne): identity_client.roles, parsed_args.role_name, ) - self.log.info('Returning existing role %s', role.name) + self.log.info(_('Returning existing role %s'), role.name) else: raise e @@ -136,12 +136,12 @@ class ListRole(command.Lister): parser.add_argument( '--project', metavar='', - help='Filter roles by (name or ID)', + help=_('Filter roles by (name or ID)'), ) parser.add_argument( '--user', metavar='', - help='Filter roles by (name or ID)', + help=_('Filter roles by (name or ID)'), ) return parser diff --git a/openstackclient/identity/v2_0/user.py b/openstackclient/identity/v2_0/user.py index bc9bf83789..f8f5df2997 100644 --- a/openstackclient/identity/v2_0/user.py +++ b/openstackclient/identity/v2_0/user.py @@ -104,7 +104,7 @@ class CreateUser(command.ShowOne): identity_client.users, parsed_args.name, ) - self.log.info('Returning existing user %s', user.name) + self.log.info(_('Returning existing user %s'), user.name) else: raise e @@ -159,7 +159,8 @@ class ListUser(command.Lister): '--long', action='store_true', default=False, - help=_('List additional fields in output')) + help=_('List additional fields in output'), + ) return parser def take_action(self, parsed_args): diff --git a/openstackclient/identity/v3/catalog.py b/openstackclient/identity/v3/catalog.py index 78d71f59ab..4c794692d4 100644 --- a/openstackclient/identity/v3/catalog.py +++ b/openstackclient/identity/v3/catalog.py @@ -84,7 +84,7 @@ class ShowCatalog(command.ShowOne): break if not data: - self.app.log.error('service %s not found\n' % + self.app.log.error(_('service %s not found\n') % parsed_args.service) return ([], []) diff --git a/openstackclient/identity/v3/consumer.py b/openstackclient/identity/v3/consumer.py index 83809e51f0..a062b74381 100644 --- a/openstackclient/identity/v3/consumer.py +++ b/openstackclient/identity/v3/consumer.py @@ -20,6 +20,7 @@ import sys from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class CreateConsumer(command.ShowOne): @@ -30,7 +31,7 @@ class CreateConsumer(command.ShowOne): parser.add_argument( '--description', metavar='', - help='New consumer description', + help=_('New consumer description'), ) return parser @@ -51,7 +52,7 @@ class DeleteConsumer(command.Command): parser.add_argument( 'consumer', metavar='', - help='Consumer to delete', + help=_('Consumer to delete'), ) return parser @@ -83,12 +84,12 @@ class SetConsumer(command.Command): parser.add_argument( 'consumer', metavar='', - help='Consumer to modify', + help=_('Consumer to modify'), ) parser.add_argument( '--description', metavar='', - help='New consumer description', + help=_('New consumer description'), ) return parser @@ -101,7 +102,7 @@ class SetConsumer(command.Command): kwargs['description'] = parsed_args.description if not len(kwargs): - sys.stdout.write('Consumer not updated, no arguments present\n') + sys.stdout.write(_('Consumer not updated, no arguments present\n')) return consumer = identity_client.oauth1.consumers.update( @@ -116,7 +117,7 @@ class ShowConsumer(command.ShowOne): parser.add_argument( 'consumer', metavar='', - help='Consumer to display', + help=_('Consumer to display'), ) return parser diff --git a/openstackclient/identity/v3/credential.py b/openstackclient/identity/v3/credential.py index b0d2cafd0b..9901347852 100644 --- a/openstackclient/identity/v3/credential.py +++ b/openstackclient/identity/v3/credential.py @@ -19,6 +19,7 @@ import six from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class CreateCredential(command.ShowOne): @@ -29,24 +30,25 @@ class CreateCredential(command.ShowOne): parser.add_argument( 'user', metavar='', - help='Name or ID of user that owns the credential', + help=_('Name or ID of user that owns the credential'), ) parser.add_argument( '--type', default="cert", metavar='', choices=['ec2', 'cert'], - help='New credential type', + help=_('New credential type'), ) parser.add_argument( 'data', metavar='', - help='New credential data', + help=_('New credential data'), ) parser.add_argument( '--project', metavar='', - help='Project name or ID which limits the scope of the credential', + help=_('Project name or ID which limits the ' + 'scope of the credential'), ) return parser @@ -77,7 +79,7 @@ class DeleteCredential(command.Command): parser.add_argument( 'credential', metavar='', - help='ID of credential to delete', + help=_('ID of credential to delete'), ) return parser @@ -108,31 +110,32 @@ class SetCredential(command.Command): parser.add_argument( 'credential', metavar='', - help='ID of credential to change', + help=_('ID of credential to change'), ) parser.add_argument( '--user', metavar='', required=True, - help='Name or ID of user that owns the credential', + help=_('Name or ID of user that owns the credential'), ) parser.add_argument( '--type', metavar='', choices=['ec2', 'cert'], required=True, - help='New credential type', + help=_('New credential type'), ) parser.add_argument( '--data', metavar='', required=True, - help='New credential data', + help=_('New credential data'), ) parser.add_argument( '--project', metavar='', - help='Project name or ID which limits the scope of the credential', + help=_('Project name or ID which limits the ' + 'scope of the credential'), ) return parser @@ -163,7 +166,7 @@ class ShowCredential(command.ShowOne): parser.add_argument( 'credential', metavar='', - help='ID of credential to display', + help=_('ID of credential to display'), ) return parser diff --git a/openstackclient/identity/v3/domain.py b/openstackclient/identity/v3/domain.py index fc5aba12fc..c345028f8a 100644 --- a/openstackclient/identity/v3/domain.py +++ b/openstackclient/identity/v3/domain.py @@ -33,23 +33,23 @@ class CreateDomain(command.ShowOne): parser.add_argument( 'name', metavar='', - help='New domain name', + help=_('New domain name'), ) parser.add_argument( '--description', metavar='', - help='New domain description', + help=_('New domain description'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', action='store_true', - help='Enable domain (default)', + help=_('Enable domain (default)'), ) enable_group.add_argument( '--disable', action='store_true', - help='Disable domain', + help=_('Disable domain'), ) parser.add_argument( '--or-show', @@ -75,7 +75,7 @@ class CreateDomain(command.ShowOne): if parsed_args.or_show: domain = utils.find_resource(identity_client.domains, parsed_args.name) - self.log.info('Returning existing domain %s', domain.name) + self.log.info(_('Returning existing domain %s'), domain.name) else: raise e @@ -91,7 +91,7 @@ class DeleteDomain(command.Command): parser.add_argument( 'domain', metavar='', - help='Domain to delete (name or ID)', + help=_('Domain to delete (name or ID)'), ) return parser @@ -123,28 +123,28 @@ class SetDomain(command.Command): parser.add_argument( 'domain', metavar='', - help='Domain to modify (name or ID)', + help=_('Domain to modify (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='New domain name', + help=_('New domain name'), ) parser.add_argument( '--description', metavar='', - help='New domain description', + help=_('New domain description'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', action='store_true', - help='Enable domain', + help=_('Enable domain'), ) enable_group.add_argument( '--disable', action='store_true', - help='Disable domain', + help=_('Disable domain'), ) return parser @@ -164,7 +164,7 @@ class SetDomain(command.Command): kwargs['enabled'] = False if not kwargs: - sys.stdout.write("Domain not updated, no arguments present\n") + sys.stdout.write(_("Domain not updated, no arguments present\n")) return identity_client.domains.update(domain.id, **kwargs) @@ -177,7 +177,7 @@ class ShowDomain(command.ShowOne): parser.add_argument( 'domain', metavar='', - help='Domain to display (name or ID)', + help=_('Domain to display (name or ID)'), ) return parser diff --git a/openstackclient/identity/v3/ec2creds.py b/openstackclient/identity/v3/ec2creds.py index a12b2d3b4e..859ec2a730 100644 --- a/openstackclient/identity/v3/ec2creds.py +++ b/openstackclient/identity/v3/ec2creds.py @@ -56,18 +56,14 @@ class CreateEC2Creds(command.ShowOne): parser.add_argument( '--project', metavar='', - help=_( - 'Create credentials in project ' - '(name or ID; default: current authenticated project)' - ), + help=_('Create credentials in project ' + '(name or ID; default: current authenticated project)'), ) parser.add_argument( '--user', metavar='', - help=_( - 'Create credentials for user ' - '(name or ID; default: current authenticated user)' - ), + help=_('Create credentials for user ' + '(name or ID; default: current authenticated user)'), ) common.add_user_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser) diff --git a/openstackclient/identity/v3/endpoint.py b/openstackclient/identity/v3/endpoint.py index 5bc9d06b8e..39022d27db 100644 --- a/openstackclient/identity/v3/endpoint.py +++ b/openstackclient/identity/v3/endpoint.py @@ -20,6 +20,7 @@ import sys from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ from openstackclient.identity import common @@ -38,23 +39,23 @@ class CreateEndpoint(command.ShowOne): parser.add_argument( 'service', metavar='', - help='New endpoint service (name or ID)', + help=_('New endpoint service (name or ID)'), ) parser.add_argument( 'interface', metavar='', choices=['admin', 'public', 'internal'], - help='New endpoint interface type (admin, public or internal)', + help=_('New endpoint interface type (admin, public or internal)'), ) parser.add_argument( 'url', metavar='', - help='New endpoint URL', + help=_('New endpoint URL'), ) parser.add_argument( '--region', metavar='', - help='New endpoint region ID', + help=_('New endpoint region ID'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( @@ -62,13 +63,13 @@ class CreateEndpoint(command.ShowOne): dest='enabled', action='store_true', default=True, - help='Enable endpoint (default)', + help=_('Enable endpoint (default)'), ) enable_group.add_argument( '--disable', dest='enabled', action='store_false', - help='Disable endpoint', + help=_('Disable endpoint'), ) return parser @@ -100,7 +101,7 @@ class DeleteEndpoint(command.Command): parser.add_argument( 'endpoint', metavar='', - help='Endpoint ID to delete', + help=_('Endpoint ID to delete'), ) return parser @@ -119,18 +120,18 @@ class ListEndpoint(command.Lister): parser.add_argument( '--service', metavar='', - help='Filter by service', + help=_('Filter by service'), ) parser.add_argument( '--interface', metavar='', choices=['admin', 'public', 'internal'], - help='Filter by interface type (admin, public or internal)', + help=_('Filter by interface type (admin, public or internal)'), ) parser.add_argument( '--region', metavar='', - help='Filter by region ID', + help=_('Filter by region ID'), ) return parser @@ -167,41 +168,41 @@ class SetEndpoint(command.Command): parser.add_argument( 'endpoint', metavar='', - help='Endpoint ID to modify', + help=_('Endpoint ID to modify'), ) parser.add_argument( '--region', metavar='', - help='New endpoint region ID', + help=_('New endpoint region ID'), ) parser.add_argument( '--interface', metavar='', choices=['admin', 'public', 'internal'], - help='New endpoint interface type (admin, public or internal)', + help=_('New endpoint interface type (admin, public or internal)'), ) parser.add_argument( '--url', metavar='', - help='New endpoint URL', + help=_('New endpoint URL'), ) parser.add_argument( '--service', metavar='', - help='New endpoint service (name or ID)', + help=_('New endpoint service (name or ID)'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', dest='enabled', action='store_true', - help='Enable endpoint', + help=_('Enable endpoint'), ) enable_group.add_argument( '--disable', dest='disabled', action='store_true', - help='Disable endpoint', + help=_('Disable endpoint'), ) return parser @@ -213,7 +214,7 @@ class SetEndpoint(command.Command): if (not parsed_args.interface and not parsed_args.url and not parsed_args.service and not parsed_args.region and not parsed_args.enabled and not parsed_args.disabled): - sys.stdout.write("Endpoint not updated, no arguments present\n") + sys.stdout.write(_("Endpoint not updated, no arguments present\n")) return service_id = None @@ -244,8 +245,8 @@ class ShowEndpoint(command.ShowOne): parser.add_argument( 'endpoint', metavar='', - help='Endpoint to display (endpoint ID, service ID,' - ' service name, service type)', + help=_('Endpoint to display (endpoint ID, service ID,' + ' service name, service type)'), ) return parser diff --git a/openstackclient/identity/v3/federation_protocol.py b/openstackclient/identity/v3/federation_protocol.py index 27c837c57b..c0f4bc93db 100644 --- a/openstackclient/identity/v3/federation_protocol.py +++ b/openstackclient/identity/v3/federation_protocol.py @@ -18,6 +18,7 @@ import six from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class CreateProtocol(command.ShowOne): @@ -28,19 +29,22 @@ class CreateProtocol(command.ShowOne): parser.add_argument( 'federation_protocol', metavar='', - help='New federation protocol name (must be unique per identity ' - ' provider)') + help=_('New federation protocol name (must be unique ' + 'per identity provider)'), + ) parser.add_argument( '--identity-provider', metavar='', required=True, - help='Identity provider that will support the new federation ' - ' protocol (name or ID) (required)') + help=_('Identity provider that will support the new federation ' + ' protocol (name or ID) (required)'), + ) parser.add_argument( '--mapping', metavar='', required=True, - help='Mapping that is to be used (name or ID) (required)') + help=_('Mapping that is to be used (name or ID) (required)'), + ) return parser @@ -69,13 +73,15 @@ class DeleteProtocol(command.Command): parser.add_argument( 'federation_protocol', metavar='', - help='Federation protocol to delete (name or ID)') + help=_('Federation protocol to delete (name or ID)'), + ) parser.add_argument( '--identity-provider', metavar='', required=True, - help='Identity provider that supports ' - '(name or ID) (required)') + help=_('Identity provider that supports ' + '(name or ID) (required)'), + ) return parser @@ -94,7 +100,8 @@ class ListProtocols(command.Lister): '--identity-provider', metavar='', required=True, - help='Identity provider to list (name or ID) (required)') + help=_('Identity provider to list (name or ID) (required)'), + ) return parser @@ -118,24 +125,27 @@ class SetProtocol(command.Command): parser.add_argument( 'federation_protocol', metavar='', - help='Federation protocol to modify (name or ID)') + help=_('Federation protocol to modify (name or ID)'), + ) parser.add_argument( '--identity-provider', metavar='', required=True, - help='Identity provider that supports ' - '(name or ID) (required)') + help=_('Identity provider that supports ' + '(name or ID) (required)'), + ) parser.add_argument( '--mapping', metavar='', - help='Mapping that is to be used (name or ID)') + help=_('Mapping that is to be used (name or ID)'), + ) return parser def take_action(self, parsed_args): identity_client = self.app.client_manager.identity if not parsed_args.mapping: - self.app.log.error("No changes requested") + self.app.log.error(_("No changes requested")) return protocol = identity_client.federation.protocols.update( @@ -159,13 +169,15 @@ class ShowProtocol(command.ShowOne): parser.add_argument( 'federation_protocol', metavar='', - help='Federation protocol to display (name or ID)') + help=_('Federation protocol to display (name or ID)'), + ) parser.add_argument( '--identity-provider', metavar='', required=True, - help=('Identity provider that supports ' - '(name or ID) (required)')) + help=_('Identity provider that supports ' + '(name or ID) (required)'), + ) return parser def take_action(self, parsed_args): diff --git a/openstackclient/identity/v3/group.py b/openstackclient/identity/v3/group.py index 8fb8a0478a..fdb94da641 100644 --- a/openstackclient/identity/v3/group.py +++ b/openstackclient/identity/v3/group.py @@ -34,12 +34,12 @@ class AddUserToGroup(command.Command): parser.add_argument( 'group', metavar='', - help='Group to contain (name or ID)', + help=_('Group to contain (name or ID)'), ) parser.add_argument( 'user', metavar='', - help='User to add to (name or ID)', + help=_('User to add to (name or ID)'), ) common.add_group_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser) @@ -58,11 +58,17 @@ class AddUserToGroup(command.Command): try: identity_client.users.add_to_group(user_id, group_id) except Exception: - sys.stderr.write("%s not added to group %s\n" % - (parsed_args.user, parsed_args.group)) + msg = _("%(user)s not added to group %(group)s\n") % { + 'user': parsed_args.user, + 'group': parsed_args.group, + } + sys.stderr.write(msg) else: - sys.stdout.write("%s added to group %s\n" % - (parsed_args.user, parsed_args.group)) + msg = _("%(user)s added to group %(group)s\n") % { + 'user': parsed_args.user, + 'group': parsed_args.group, + } + sys.stdout.write(msg) class CheckUserInGroup(command.Command): @@ -73,12 +79,12 @@ class CheckUserInGroup(command.Command): parser.add_argument( 'group', metavar='', - help='Group to check (name or ID)', + help=_('Group to check (name or ID)'), ) parser.add_argument( 'user', metavar='', - help='User to check (name or ID)', + help=_('User to check (name or ID)'), ) common.add_group_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser) @@ -97,11 +103,17 @@ class CheckUserInGroup(command.Command): try: identity_client.users.check_in_group(user_id, group_id) except Exception: - sys.stderr.write("%s not in group %s\n" % - (parsed_args.user, parsed_args.group)) + msg = _("%(user)s not in group %(group)s\n") % { + 'user': parsed_args.user, + 'group': parsed_args.group, + } + sys.stderr.write(msg) else: - sys.stdout.write("%s in group %s\n" % - (parsed_args.user, parsed_args.group)) + msg = _("%(user)s in group %(group)s\n") % { + 'user': parsed_args.user, + 'group': parsed_args.group, + } + sys.stdout.write(msg) class CreateGroup(command.ShowOne): @@ -112,17 +124,17 @@ class CreateGroup(command.ShowOne): parser.add_argument( 'name', metavar='', - help='New group name', + help=_('New group name'), ) parser.add_argument( '--domain', metavar='', - help='Domain to contain new group (name or ID)', + help=_('Domain to contain new group (name or ID)'), ) parser.add_argument( '--description', metavar='', - help='New group description', + help=_('New group description'), ) parser.add_argument( '--or-show', @@ -149,7 +161,7 @@ class CreateGroup(command.ShowOne): group = utils.find_resource(identity_client.groups, parsed_args.name, domain_id=domain) - self.log.info('Returning existing group %s', group.name) + self.log.info(_('Returning existing group %s'), group.name) else: raise e @@ -166,11 +178,12 @@ class DeleteGroup(command.Command): 'groups', metavar='', nargs="+", - help='Group(s) to delete (name or ID)') + help=_('Group(s) to delete (name or ID)'), + ) parser.add_argument( '--domain', metavar='', - help='Domain containing group(s) (name or ID)', + help=_('Domain containing group(s) (name or ID)'), ) return parser @@ -192,19 +205,19 @@ class ListGroup(command.Lister): parser.add_argument( '--domain', metavar='', - help='Filter group list by (name or ID)', + help=_('Filter group list by (name or ID)'), ) parser.add_argument( '--user', metavar='', - help='Filter group list by (name or ID)', + help=_('Filter group list by (name or ID)'), ) common.add_user_domain_option_to_parser(parser) parser.add_argument( '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -252,12 +265,12 @@ class RemoveUserFromGroup(command.Command): parser.add_argument( 'group', metavar='', - help='Group containing (name or ID)', + help=_('Group containing (name or ID)'), ) parser.add_argument( 'user', metavar='', - help='User to remove from (name or ID)', + help=_('User to remove from (name or ID)'), ) common.add_group_domain_option_to_parser(parser) common.add_user_domain_option_to_parser(parser) @@ -276,11 +289,17 @@ class RemoveUserFromGroup(command.Command): try: identity_client.users.remove_from_group(user_id, group_id) except Exception: - sys.stderr.write("%s not removed from group %s\n" % - (parsed_args.user, parsed_args.group)) + msg = _("%(user)s not removed from group %(group)s\n") % { + 'user': parsed_args.user, + 'group': parsed_args.group, + } + sys.stderr.write(msg) else: - sys.stdout.write("%s removed from group %s\n" % - (parsed_args.user, parsed_args.group)) + msg = _("%(user)s removed from group %(group)s\n") % { + 'user': parsed_args.user, + 'group': parsed_args.group, + } + sys.stdout.write(msg) class SetGroup(command.Command): @@ -291,20 +310,23 @@ class SetGroup(command.Command): parser.add_argument( 'group', metavar='', - help='Group to modify (name or ID)') + help=_('Group to modify (name or ID)'), + ) parser.add_argument( '--domain', metavar='', - help='Domain containing (name or ID)', + help=_('Domain containing (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='New group name') + help=_('New group name'), + ) parser.add_argument( '--description', metavar='', - help='New group description') + help=_('New group description'), + ) return parser def take_action(self, parsed_args): @@ -331,12 +353,12 @@ class ShowGroup(command.ShowOne): parser.add_argument( 'group', metavar='', - help='Group to display (name or ID)', + help=_('Group to display (name or ID)'), ) parser.add_argument( '--domain', metavar='', - help='Domain containing (name or ID)', + help=_('Domain containing (name or ID)'), ) return parser diff --git a/openstackclient/identity/v3/identity_provider.py b/openstackclient/identity/v3/identity_provider.py index 39f440f4fd..3749aa35e5 100644 --- a/openstackclient/identity/v3/identity_provider.py +++ b/openstackclient/identity/v3/identity_provider.py @@ -17,6 +17,7 @@ import six from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class CreateIdentityProvider(command.ShowOne): @@ -27,26 +28,26 @@ class CreateIdentityProvider(command.ShowOne): parser.add_argument( 'identity_provider_id', metavar='', - help='New identity provider name (must be unique)' + help=_('New identity provider name (must be unique)'), ) identity_remote_id_provider = parser.add_mutually_exclusive_group() identity_remote_id_provider.add_argument( '--remote-id', metavar='', action='append', - help='Remote IDs to associate with the Identity Provider ' - '(repeat option to provide multiple values)' + help=_('Remote IDs to associate with the Identity Provider ' + '(repeat option to provide multiple values)'), ) identity_remote_id_provider.add_argument( '--remote-id-file', metavar='', - help='Name of a file that contains many remote IDs to associate ' - 'with the identity provider, one per line' + help=_('Name of a file that contains many remote IDs to associate ' + 'with the identity provider, one per line'), ) parser.add_argument( '--description', metavar='', - help='New identity provider description', + help=_('New identity provider description'), ) enable_identity_provider = parser.add_mutually_exclusive_group() enable_identity_provider.add_argument( @@ -54,13 +55,13 @@ class CreateIdentityProvider(command.ShowOne): dest='enabled', action='store_true', default=True, - help='Enable identity provider (default)', + help=_('Enable identity provider (default)'), ) enable_identity_provider.add_argument( '--disable', dest='enabled', action='store_false', - help='Disable the identity provider', + help=_('Disable the identity provider'), ) return parser @@ -94,7 +95,7 @@ class DeleteIdentityProvider(command.Command): parser.add_argument( 'identity_provider', metavar='', - help='Identity provider to delete', + help=_('Identity provider to delete'), ) return parser @@ -126,37 +127,37 @@ class SetIdentityProvider(command.Command): parser.add_argument( 'identity_provider', metavar='', - help='Identity provider to modify', + help=_('Identity provider to modify'), ) parser.add_argument( '--description', metavar='', - help='Set identity provider description', + help=_('Set identity provider description'), ) identity_remote_id_provider = parser.add_mutually_exclusive_group() identity_remote_id_provider.add_argument( '--remote-id', metavar='', action='append', - help='Remote IDs to associate with the Identity Provider ' - '(repeat option to provide multiple values)' + help=_('Remote IDs to associate with the Identity Provider ' + '(repeat option to provide multiple values)'), ) identity_remote_id_provider.add_argument( '--remote-id-file', metavar='', - help='Name of a file that contains many remote IDs to associate ' - 'with the identity provider, one per line' + help=_('Name of a file that contains many remote IDs to associate ' + 'with the identity provider, one per line'), ) enable_identity_provider = parser.add_mutually_exclusive_group() enable_identity_provider.add_argument( '--enable', action='store_true', - help='Enable the identity provider', + help=_('Enable the identity provider'), ) enable_identity_provider.add_argument( '--disable', action='store_true', - help='Disable the identity provider', + help=_('Disable the identity provider'), ) return parser @@ -168,7 +169,7 @@ class SetIdentityProvider(command.Command): not parsed_args.remote_id and not parsed_args.remote_id_file and not parsed_args.description): - self.log.error('No changes requested') + self.log.error(_('No changes requested')) return (None, None) # Always set remote_ids if either is passed in @@ -206,7 +207,7 @@ class ShowIdentityProvider(command.ShowOne): parser.add_argument( 'identity_provider', metavar='', - help='Identity provider to display', + help=_('Identity provider to display'), ) return parser diff --git a/openstackclient/identity/v3/mapping.py b/openstackclient/identity/v3/mapping.py index 3cdc8afc99..c45796e482 100644 --- a/openstackclient/identity/v3/mapping.py +++ b/openstackclient/identity/v3/mapping.py @@ -22,6 +22,7 @@ import six from openstackclient.common import command from openstackclient.common import exceptions from openstackclient.common import utils +from openstackclient.i18n import _ class _RulesReader(object): @@ -69,9 +70,9 @@ class _RulesReader(object): try: rules = json.loads(blob) except ValueError as e: - raise exceptions.CommandError( - 'An error occurred when reading ' - 'rules from file %s: %s' % (path, e)) + msg = _("An error occurred when reading rules from file " + "%(path)s: %(error)s") % {"path": path, "error": e} + raise exceptions.CommandError(msg) else: return rules @@ -84,12 +85,12 @@ class CreateMapping(command.ShowOne, _RulesReader): parser.add_argument( 'mapping', metavar='', - help='New mapping name (must be unique)', + help=_('New mapping name (must be unique)'), ) parser.add_argument( '--rules', metavar='', required=True, - help='Filename that contains a set of mapping rules (required)', + help=_('Filename that contains a set of mapping rules (required)'), ) return parser @@ -113,7 +114,7 @@ class DeleteMapping(command.Command): parser.add_argument( 'mapping', metavar='', - help='Mapping to delete', + help=_('Mapping to delete'), ) return parser @@ -145,12 +146,12 @@ class SetMapping(command.Command, _RulesReader): parser.add_argument( 'mapping', metavar='', - help='Mapping to modify', + help=_('Mapping to modify'), ) parser.add_argument( '--rules', metavar='', - help='Filename that contains a new set of mapping rules', + help=_('Filename that contains a new set of mapping rules'), ) return parser @@ -158,7 +159,7 @@ class SetMapping(command.Command, _RulesReader): identity_client = self.app.client_manager.identity if not parsed_args.rules: - self.app.log.error("No changes requested") + self.app.log.error(_("No changes requested")) return rules = self._read_rules(parsed_args.rules) @@ -179,7 +180,7 @@ class ShowMapping(command.ShowOne): parser.add_argument( 'mapping', metavar='', - help='Mapping to display', + help=_('Mapping to display'), ) return parser diff --git a/openstackclient/identity/v3/policy.py b/openstackclient/identity/v3/policy.py index 3c2d1a7c94..74a783b06a 100644 --- a/openstackclient/identity/v3/policy.py +++ b/openstackclient/identity/v3/policy.py @@ -20,6 +20,7 @@ import sys from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class CreatePolicy(command.ShowOne): @@ -31,13 +32,13 @@ class CreatePolicy(command.ShowOne): '--type', metavar='', default="application/json", - help='New MIME type of the policy rules file ' - '(defaults to application/json)', + help=_('New MIME type of the policy rules file ' + '(defaults to application/json)'), ) parser.add_argument( 'rules', metavar='', - help='New serialized policy rules file', + help=_('New serialized policy rules file'), ) return parser @@ -62,7 +63,7 @@ class DeletePolicy(command.Command): parser.add_argument( 'policy', metavar='', - help='Policy to delete', + help=_('Policy to delete'), ) return parser @@ -80,7 +81,7 @@ class ListPolicy(command.Lister): '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -107,17 +108,17 @@ class SetPolicy(command.Command): parser.add_argument( 'policy', metavar='', - help='Policy to modify', + help=_('Policy to modify'), ) parser.add_argument( '--type', metavar='', - help='New MIME type of the policy rules file', + help=_('New MIME type of the policy rules file'), ) parser.add_argument( '--rules', metavar='', - help='New serialized policy rules file', + help=_('New serialized policy rules file'), ) return parser @@ -135,7 +136,7 @@ class SetPolicy(command.Command): kwargs['type'] = parsed_args.type if not kwargs: - sys.stdout.write('Policy not updated, no arguments present \n') + sys.stdout.write(_('Policy not updated, no arguments present\n')) return identity_client.policies.update(parsed_args.policy, **kwargs) @@ -148,7 +149,7 @@ class ShowPolicy(command.ShowOne): parser.add_argument( 'policy', metavar='', - help='Policy to display', + help=_('Policy to display'), ) return parser diff --git a/openstackclient/identity/v3/project.py b/openstackclient/identity/v3/project.py index 4990b1b9a3..acf639f29d 100644 --- a/openstackclient/identity/v3/project.py +++ b/openstackclient/identity/v3/project.py @@ -34,40 +34,40 @@ class CreateProject(command.ShowOne): parser.add_argument( 'name', metavar='', - help='New project name', + help=_('New project name'), ) parser.add_argument( '--domain', metavar='', - help='Domain owning the project (name or ID)', + help=_('Domain owning the project (name or ID)'), ) parser.add_argument( '--parent', metavar='', - help='Parent of the project (name or ID)', + help=_('Parent of the project (name or ID)'), ) parser.add_argument( '--description', metavar='', - help='Project description', + help=_('Project description'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', action='store_true', - help='Enable project', + help=_('Enable project'), ) enable_group.add_argument( '--disable', action='store_true', - help='Disable project', + help=_('Disable project'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Add a property to ' - '(repeat option to set multiple properties)', + help=_('Add a property to ' + '(repeat option to set multiple properties)'), ) parser.add_argument( '--or-show', @@ -112,7 +112,7 @@ class CreateProject(command.ShowOne): project = utils.find_resource(identity_client.projects, parsed_args.name, domain_id=domain) - self.log.info('Returning existing project %s', project.name) + self.log.info(_('Returning existing project %s'), project.name) else: raise e @@ -129,12 +129,12 @@ class DeleteProject(command.Command): 'projects', metavar='', nargs="+", - help='Project(s) to delete (name or ID)', + help=_('Project(s) to delete (name or ID)'), ) parser.add_argument( '--domain', metavar='', - help='Domain owning (name or ID)', + help=_('Domain owning (name or ID)'), ) return parser @@ -163,18 +163,18 @@ class ListProject(command.Lister): parser.add_argument( '--domain', metavar='', - help='Filter projects by (name or ID)', + help=_('Filter projects by (name or ID)'), ) parser.add_argument( '--user', metavar='', - help='Filter projects by (name or ID)', + help=_('Filter projects by (name or ID)'), ) parser.add_argument( '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -219,40 +219,40 @@ class SetProject(command.Command): parser.add_argument( 'project', metavar='', - help='Project to modify (name or ID)', + help=_('Project to modify (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='Set project name', + help=_('Set project name'), ) parser.add_argument( '--domain', metavar='', - help='Domain owning (name or ID)', + help=_('Domain owning (name or ID)'), ) parser.add_argument( '--description', metavar='', - help='Set project description', + help=_('Set project description'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', action='store_true', - help='Enable project', + help=_('Enable project'), ) enable_group.add_argument( '--disable', action='store_true', - help='Disable project', + help=_('Disable project'), ) parser.add_argument( '--property', metavar='', action=parseractions.KeyValueAction, - help='Set a property on ' - '(repeat option to set multiple properties)', + help=_('Set a property on ' + '(repeat option to set multiple properties)'), ) return parser @@ -293,24 +293,24 @@ class ShowProject(command.ShowOne): parser.add_argument( 'project', metavar='', - help='Project to display (name or ID)', + help=_('Project to display (name or ID)'), ) parser.add_argument( '--domain', metavar='', - help='Domain owning (name or ID)', + help=_('Domain owning (name or ID)'), ) parser.add_argument( '--parents', action='store_true', default=False, - help='Show the project\'s parents as a list', + help=_('Show the project\'s parents as a list'), ) parser.add_argument( '--children', action='store_true', default=False, - help='Show project\'s subtree (children) as a list', + help=_('Show project\'s subtree (children) as a list'), ) return parser diff --git a/openstackclient/identity/v3/role.py b/openstackclient/identity/v3/role.py index f93c9d804f..e7078f44c6 100644 --- a/openstackclient/identity/v3/role.py +++ b/openstackclient/identity/v3/role.py @@ -31,23 +31,23 @@ def _add_identity_and_resource_options_to_parser(parser): domain_or_project.add_argument( '--domain', metavar='', - help='Include (name or ID)', + help=_('Include (name or ID)'), ) domain_or_project.add_argument( '--project', metavar='', - help='Include (name or ID)', + help=_('Include (name or ID)'), ) user_or_group = parser.add_mutually_exclusive_group() user_or_group.add_argument( '--user', metavar='', - help='Include (name or ID)', + help=_('Include (name or ID)'), ) user_or_group.add_argument( '--group', metavar='', - help='Include (name or ID)', + help=_('Include (name or ID)'), ) common.add_group_domain_option_to_parser(parser) common.add_project_domain_option_to_parser(parser) @@ -112,7 +112,7 @@ class AddRole(command.Command): parser.add_argument( 'role', metavar='', - help='Role to add to (name or ID)', + help=_('Role to add to (name or ID)'), ) _add_identity_and_resource_options_to_parser(parser) return parser @@ -131,9 +131,9 @@ class AddRole(command.Command): kwargs = _process_identity_and_resource_options( parsed_args, self.app.client_manager.identity) if not kwargs: - sys.stderr.write("Role not added, incorrect set of arguments " - "provided. See openstack --help for more " - "details\n") + sys.stderr.write(_("Role not added, incorrect set of arguments " + "provided. See openstack --help for more " + "details\n")) return identity_client.roles.grant(role.id, **kwargs) @@ -147,7 +147,7 @@ class CreateRole(command.ShowOne): parser.add_argument( 'name', metavar='', - help='New role name', + help=_('New role name'), ) parser.add_argument( '--or-show', @@ -165,7 +165,7 @@ class CreateRole(command.ShowOne): if parsed_args.or_show: role = utils.find_resource(identity_client.roles, parsed_args.name) - self.log.info('Returning existing role %s', role.name) + self.log.info(_('Returning existing role %s'), role.name) else: raise e @@ -182,7 +182,7 @@ class DeleteRole(command.Command): 'roles', metavar='', nargs="+", - help='Role(s) to delete (name or ID)', + help=_('Role(s) to delete (name or ID)'), ) return parser @@ -285,9 +285,9 @@ class ListRole(command.Lister): group_role.group = group.name group_role.project = project.name else: - sys.stderr.write("Error: If a user or group is specified, either " - "--domain or --project must also be specified to " - "list role grants.\n") + sys.stderr.write(_("Error: If a user or group is specified, " + "either --domain or --project must also be " + "specified to list role grants.\n")) return ([], []) return (columns, @@ -305,7 +305,7 @@ class RemoveRole(command.Command): parser.add_argument( 'role', metavar='', - help='Role to remove (name or ID)', + help=_('Role to remove (name or ID)'), ) _add_identity_and_resource_options_to_parser(parser) return parser @@ -315,9 +315,8 @@ class RemoveRole(command.Command): if (not parsed_args.user and not parsed_args.domain and not parsed_args.group and not parsed_args.project): - sys.stderr.write("Incorrect set of arguments " - "provided. See openstack --help for more " - "details\n") + sys.stderr.write(_("Incorrect set of arguments provided. " + "See openstack --help for more details\n")) return role = utils.find_resource( identity_client.roles, @@ -327,8 +326,9 @@ class RemoveRole(command.Command): kwargs = _process_identity_and_resource_options( parsed_args, self.app.client_manager.identity) if not kwargs: - sys.stderr.write("Role not removed, incorrect set of arguments \ - provided. See openstack --help for more details\n") + sys.stderr.write(_("Role not removed, incorrect set of arguments " + "provided. See openstack --help for more " + "details\n")) return identity_client.roles.revoke(role.id, **kwargs) @@ -341,12 +341,12 @@ class SetRole(command.Command): parser.add_argument( 'role', metavar='', - help='Role to modify (name or ID)', + help=_('Role to modify (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='Set role name', + help=_('Set role name'), ) return parser @@ -354,9 +354,8 @@ class SetRole(command.Command): identity_client = self.app.client_manager.identity if not parsed_args.name: - sys.stderr.write("Incorrect set of arguments " - "provided. See openstack --help for more " - "details\n") + sys.stderr.write(_("Incorrect set of arguments provided. " + "See openstack --help for more details\n")) return role = utils.find_resource( identity_client.roles, @@ -374,7 +373,7 @@ class ShowRole(command.ShowOne): parser.add_argument( 'role', metavar='', - help='Role to display (name or ID)', + help=_('Role to display (name or ID)'), ) return parser diff --git a/openstackclient/identity/v3/role_assignment.py b/openstackclient/identity/v3/role_assignment.py index a1418a8221..521075fef5 100644 --- a/openstackclient/identity/v3/role_assignment.py +++ b/openstackclient/identity/v3/role_assignment.py @@ -15,6 +15,7 @@ from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ from openstackclient.identity import common @@ -27,41 +28,41 @@ class ListRoleAssignment(command.Lister): '--effective', action="store_true", default=False, - help='Returns only effective role assignments', + help=_('Returns only effective role assignments'), ) parser.add_argument( '--role', metavar='', - help='Role to filter (name or ID)', + help=_('Role to filter (name or ID)'), ) parser.add_argument( '--names', action="store_true", - help='Display names instead of IDs', + help=_('Display names instead of IDs'), ) user_or_group = parser.add_mutually_exclusive_group() user_or_group.add_argument( '--user', metavar='', - help='User to filter (name or ID)', + help=_('User to filter (name or ID)'), ) common.add_user_domain_option_to_parser(parser) user_or_group.add_argument( '--group', metavar='', - help='Group to filter (name or ID)', + help=_('Group to filter (name or ID)'), ) common.add_group_domain_option_to_parser(parser) domain_or_project = parser.add_mutually_exclusive_group() domain_or_project.add_argument( '--domain', metavar='', - help='Domain to filter (name or ID)', + help=_('Domain to filter (name or ID)'), ) domain_or_project.add_argument( '--project', metavar='', - help='Project to filter (name or ID)', + help=_('Project to filter (name or ID)'), ) common.add_project_domain_option_to_parser(parser) common.add_inherited_option_to_parser(parser) diff --git a/openstackclient/identity/v3/service.py b/openstackclient/identity/v3/service.py index f43ada56e4..35507a63c4 100644 --- a/openstackclient/identity/v3/service.py +++ b/openstackclient/identity/v3/service.py @@ -20,6 +20,7 @@ import sys from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ from openstackclient.identity import common @@ -31,28 +32,28 @@ class CreateService(command.ShowOne): parser.add_argument( 'type', metavar='', - help='New service type (compute, image, identity, volume, etc)', + help=_('New service type (compute, image, identity, volume, etc)'), ) parser.add_argument( '--name', metavar='', - help='New service name', + help=_('New service name'), ) parser.add_argument( '--description', metavar='', - help='New service description', + help=_('New service description'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', action='store_true', - help='Enable service (default)', + help=_('Enable service (default)'), ) enable_group.add_argument( '--disable', action='store_true', - help='Disable service', + help=_('Disable service'), ) return parser @@ -82,7 +83,7 @@ class DeleteService(command.Command): parser.add_argument( 'service', metavar='', - help='Service to delete (type, name or ID)', + help=_('Service to delete (type, name or ID)'), ) return parser @@ -103,7 +104,7 @@ class ListService(command.Lister): '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -128,33 +129,33 @@ class SetService(command.Command): parser.add_argument( 'service', metavar='', - help='Service to update (type, name or ID)', + help=_('Service to update (type, name or ID)'), ) parser.add_argument( '--type', metavar='', - help='New service type (compute, image, identity, volume, etc)', + help=_('New service type (compute, image, identity, volume, etc)'), ) parser.add_argument( '--name', metavar='', - help='New service name', + help=_('New service name'), ) parser.add_argument( '--description', metavar='', - help='New service description', + help=_('New service description'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', action='store_true', - help='Enable service', + help=_('Enable service'), ) enable_group.add_argument( '--disable', action='store_true', - help='Disable service', + help=_('Disable service'), ) return parser @@ -166,9 +167,8 @@ class SetService(command.Command): and not parsed_args.description and not parsed_args.enable and not parsed_args.disable): - sys.stderr.write("Incorrect set of arguments " - "provided. See openstack --help for more " - "details\n") + sys.stderr.write(_("Incorrect set of arguments provided. " + "See openstack --help for more details\n")) return service = common.find_service(identity_client, parsed_args.service) @@ -198,7 +198,7 @@ class ShowService(command.ShowOne): parser.add_argument( 'service', metavar='', - help='Service to display (type, name or ID)', + help=_('Service to display (type, name or ID)'), ) return parser diff --git a/openstackclient/identity/v3/service_provider.py b/openstackclient/identity/v3/service_provider.py index d4fe287eec..f1e9f35d07 100644 --- a/openstackclient/identity/v3/service_provider.py +++ b/openstackclient/identity/v3/service_provider.py @@ -18,6 +18,7 @@ import sys from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ class CreateServiceProvider(command.ShowOne): @@ -28,26 +29,26 @@ class CreateServiceProvider(command.ShowOne): parser.add_argument( 'service_provider_id', metavar='', - help='New service provider name (must be unique)' + help=_('New service provider name (must be unique)'), ) parser.add_argument( '--auth-url', metavar='', required=True, - help='Authentication URL of remote federated service provider ' - '(required)', + help=_('Authentication URL of remote federated service provider ' + '(required)'), ) parser.add_argument( '--description', metavar='', - help='New service provider description', + help=_('New service provider description'), ) parser.add_argument( '--service-provider-url', metavar='', required=True, - help='A service URL where SAML assertions are being sent ' - '(required)', + help=_('A service URL where SAML assertions are being sent ' + '(required)'), ) enable_service_provider = parser.add_mutually_exclusive_group() @@ -56,13 +57,13 @@ class CreateServiceProvider(command.ShowOne): dest='enabled', action='store_true', default=True, - help='Enable the service provider (default)', + help=_('Enable the service provider (default)'), ) enable_service_provider.add_argument( '--disable', dest='enabled', action='store_false', - help='Disable the service provider', + help=_('Disable the service provider'), ) return parser @@ -88,7 +89,7 @@ class DeleteServiceProvider(command.Command): parser.add_argument( 'service_provider', metavar='', - help='Service provider to delete', + help=_('Service provider to delete'), ) return parser @@ -121,34 +122,35 @@ class SetServiceProvider(command.Command): parser.add_argument( 'service_provider', metavar='', - help='Service provider to modify', + help=_('Service provider to modify'), ) parser.add_argument( '--auth-url', metavar='', - help='New Authentication URL of remote federated service provider', + help=_('New Authentication URL of remote ' + 'federated service provider'), ) parser.add_argument( '--description', metavar='', - help='New service provider description', + help=_('New service provider description'), ) parser.add_argument( '--service-provider-url', metavar='', - help='New service provider URL, where SAML assertions are sent', + help=_('New service provider URL, where SAML assertions are sent'), ) enable_service_provider = parser.add_mutually_exclusive_group() enable_service_provider.add_argument( '--enable', action='store_true', - help='Enable the service provider', + help=_('Enable the service provider'), ) enable_service_provider.add_argument( '--disable', action='store_true', - help='Disable the service provider', + help=_('Disable the service provider'), ) return parser @@ -164,8 +166,8 @@ class SetServiceProvider(command.Command): if not any((enabled is not None, parsed_args.description, parsed_args.service_provider_url, parsed_args.auth_url)): - sys.stdout.write("Service Provider not updated, no arguments " - "present\n") + sys.stdout.write(_("Service Provider not updated, no arguments " + "present\n")) return (None, None) service_provider = federation_client.service_providers.update( @@ -184,7 +186,7 @@ class ShowServiceProvider(command.ShowOne): parser.add_argument( 'service_provider', metavar='', - help='Service provider to display', + help=_('Service provider to display'), ) return parser diff --git a/openstackclient/identity/v3/token.py b/openstackclient/identity/v3/token.py index bdc5e95f69..56a7497cfc 100644 --- a/openstackclient/identity/v3/token.py +++ b/openstackclient/identity/v3/token.py @@ -20,6 +20,7 @@ import six from openstackclient.common import command from openstackclient.common import exceptions from openstackclient.common import utils +from openstackclient.i18n import _ from openstackclient.identity import common @@ -31,17 +32,17 @@ class AuthorizeRequestToken(command.ShowOne): parser.add_argument( '--request-key', metavar='', - help='Request token to authorize (ID only) (required)', - required=True + required=True, + help=_('Request token to authorize (ID only) (required)'), ) parser.add_argument( '--role', metavar='', action='append', default=[], - help='Roles to authorize (name or ID) ' - '(repeat option to set multiple values, required)', - required=True + required=True, + help=_('Roles to authorize (name or ID) ' + '(repeat option to set multiple values, required)'), ) return parser @@ -72,31 +73,31 @@ class CreateAccessToken(command.ShowOne): parser.add_argument( '--consumer-key', metavar='', - help='Consumer key (required)', + help=_('Consumer key (required)'), required=True ) parser.add_argument( '--consumer-secret', metavar='', - help='Consumer secret (required)', + help=_('Consumer secret (required)'), required=True ) parser.add_argument( '--request-key', metavar='', - help='Request token to exchange for access token (required)', + help=_('Request token to exchange for access token (required)'), required=True ) parser.add_argument( '--request-secret', metavar='', - help='Secret associated with (required)', + help=_('Secret associated with (required)'), required=True ) parser.add_argument( '--verifier', metavar='', - help='Verifier associated with (required)', + help=_('Verifier associated with (required)'), required=True ) return parser @@ -118,26 +119,26 @@ class CreateRequestToken(command.ShowOne): parser.add_argument( '--consumer-key', metavar='', - help='Consumer key (required)', + help=_('Consumer key (required)'), required=True ) parser.add_argument( '--consumer-secret', metavar='', - help='Consumer secret (required)', + help=_('Consumer secret (required)'), required=True ) parser.add_argument( '--project', metavar='', - help='Project that consumer wants to access (name or ID)' - ' (required)', + help=_('Project that consumer wants to access (name or ID)' + ' (required)'), required=True ) parser.add_argument( '--domain', metavar='', - help='Domain owning (name or ID)', + help=_('Domain owning (name or ID)'), ) return parser @@ -175,7 +176,7 @@ class IssueToken(command.ShowOne): def take_action(self, parsed_args): if not self.app.client_manager.auth_ref: raise exceptions.AuthorizationFailure( - "Only an authorized user may issue a new token.") + _("Only an authorized user may issue a new token.")) token = self.app.client_manager.auth_ref.service_catalog.get_token() if 'tenant_id' in token: token['project_id'] = token.pop('tenant_id') @@ -190,7 +191,7 @@ class RevokeToken(command.Command): parser.add_argument( 'token', metavar='', - help='Token to be deleted', + help=_('Token to be deleted'), ) return parser diff --git a/openstackclient/identity/v3/trust.py b/openstackclient/identity/v3/trust.py index b6f5c6b41f..336b703cbd 100644 --- a/openstackclient/identity/v3/trust.py +++ b/openstackclient/identity/v3/trust.py @@ -18,6 +18,7 @@ import six from openstackclient.common import command from openstackclient.common import utils +from openstackclient.i18n import _ from openstackclient.identity import common @@ -29,26 +30,26 @@ class CreateTrust(command.ShowOne): parser.add_argument( 'trustor', metavar='', - help='User that is delegating authorization (name or ID)', + help=_('User that is delegating authorization (name or ID)'), ) parser.add_argument( 'trustee', metavar='', - help='User that is assuming authorization (name or ID)', + help=_('User that is assuming authorization (name or ID)'), ) parser.add_argument( '--project', metavar='', required=True, - help='Project being delegated (name or ID) (required)', + help=_('Project being delegated (name or ID) (required)'), ) parser.add_argument( '--role', metavar='', action='append', default=[], - help='Roles to authorize (name or ID) ' - '(repeat option to set multiple values, required)', + help=_('Roles to authorize (name or ID) ' + '(repeat option to set multiple values, required)'), required=True ) parser.add_argument( @@ -56,25 +57,25 @@ class CreateTrust(command.ShowOne): dest='impersonate', action='store_true', default=False, - help='Tokens generated from the trust will represent ' - ' (defaults to False)', + help=_('Tokens generated from the trust will represent ' + ' (defaults to False)'), ) parser.add_argument( '--expiration', metavar='', - help='Sets an expiration date for the trust' - ' (format of YYYY-mm-ddTHH:MM:SS)', + help=_('Sets an expiration date for the trust' + ' (format of YYYY-mm-ddTHH:MM:SS)'), ) common.add_project_domain_option_to_parser(parser) parser.add_argument( '--trustor-domain', metavar='', - help='Domain that contains (name or ID)', + help=_('Domain that contains (name or ID)'), ) parser.add_argument( '--trustee-domain', metavar='', - help='Domain that contains (name or ID)', + help=_('Domain that contains (name or ID)'), ) return parser @@ -136,8 +137,8 @@ class DeleteTrust(command.Command): parser.add_argument( 'trust', metavar='', - help='Trust(s) to delete', nargs="+", + help=_('Trust(s) to delete'), ) return parser @@ -170,7 +171,7 @@ class ShowTrust(command.ShowOne): parser.add_argument( 'trust', metavar='', - help='Trust to display', + help=_('Trust to display'), ) return parser diff --git a/openstackclient/identity/v3/unscoped_saml.py b/openstackclient/identity/v3/unscoped_saml.py index 8e2616a691..5cb8e4868d 100644 --- a/openstackclient/identity/v3/unscoped_saml.py +++ b/openstackclient/identity/v3/unscoped_saml.py @@ -20,6 +20,7 @@ a scoped token.""" from openstackclient.common import command from openstackclient.common import exceptions from openstackclient.common import utils +from openstackclient.i18n import _ UNSCOPED_AUTH_PLUGINS = ['v3unscopedsaml', 'v3unscopedadfs', 'v3oidc'] @@ -33,10 +34,10 @@ def auth_with_unscoped_saml(func): if auth_plugin_name in UNSCOPED_AUTH_PLUGINS: return func(self, parsed_args) else: - msg = ('This command requires the use of an unscoped SAML ' - 'authentication plugin. Please use argument ' - '--os-auth-type with one of the following ' - 'plugins: ' + ', '.join(UNSCOPED_AUTH_PLUGINS)) + msg = (_('This command requires the use of an unscoped SAML ' + 'authentication plugin. Please use argument ' + '--os-auth-type with one of the following ' + 'plugins: %s') % ', '.join(UNSCOPED_AUTH_PLUGINS)) raise exceptions.CommandError(msg) return _decorated diff --git a/openstackclient/identity/v3/user.py b/openstackclient/identity/v3/user.py index 8bc4183b4d..a71b4b7808 100644 --- a/openstackclient/identity/v3/user.py +++ b/openstackclient/identity/v3/user.py @@ -35,50 +35,50 @@ class CreateUser(command.ShowOne): parser.add_argument( 'name', metavar='', - help='New user name', + help=_('New user name'), ) parser.add_argument( '--domain', metavar='', - help='Default domain (name or ID)', + help=_('Default domain (name or ID)'), ) parser.add_argument( '--project', metavar='', - help='Default project (name or ID)', + help=_('Default project (name or ID)'), ) common.add_project_domain_option_to_parser(parser) parser.add_argument( '--password', metavar='', - help='Set user password', + help=_('Set user password'), ) parser.add_argument( '--password-prompt', dest="password_prompt", action="store_true", - help='Prompt interactively for password', + help=_('Prompt interactively for password'), ) parser.add_argument( '--email', metavar='', - help='Set user email address', + help=_('Set user email address'), ) parser.add_argument( '--description', metavar='', - help='User description', + help=_('User description'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', action='store_true', - help='Enable user (default)', + help=_('Enable user (default)'), ) enable_group.add_argument( '--disable', action='store_true', - help='Disable user', + help=_('Disable user'), ) parser.add_argument( '--or-show', @@ -122,7 +122,7 @@ class CreateUser(command.ShowOne): user = utils.find_resource(identity_client.users, parsed_args.name, domain_id=domain_id) - self.log.info('Returning existing user %s', user.name) + self.log.info(_('Returning existing user %s'), user.name) else: raise e @@ -139,12 +139,12 @@ class DeleteUser(command.Command): 'users', metavar='', nargs="+", - help='User(s) to delete (name or ID)', + help=_('User(s) to delete (name or ID)'), ) parser.add_argument( '--domain', metavar='', - help='Domain owning (name or ID)', + help=_('Domain owning (name or ID)'), ) return parser @@ -173,24 +173,24 @@ class ListUser(command.Lister): parser.add_argument( '--domain', metavar='', - help='Filter users by (name or ID)', + help=_('Filter users by (name or ID)'), ) project_or_group = parser.add_mutually_exclusive_group() project_or_group.add_argument( '--group', metavar='', - help='Filter users by membership (name or ID)', + help=_('Filter users by membership (name or ID)'), ) project_or_group.add_argument( '--project', metavar='', - help='Filter users by (name or ID)', + help=_('Filter users by (name or ID)'), ) parser.add_argument( '--long', action='store_true', default=False, - help='List additional fields in output', + help=_('List additional fields in output'), ) return parser @@ -273,50 +273,50 @@ class SetUser(command.Command): parser.add_argument( 'user', metavar='', - help='User to change (name or ID)', + help=_('User to change (name or ID)'), ) parser.add_argument( '--name', metavar='', - help='Set user name', + help=_('Set user name'), ) parser.add_argument( '--project', metavar='', - help='Set default project (name or ID)', + help=_('Set default project (name or ID)'), ) common.add_project_domain_option_to_parser(parser) parser.add_argument( '--password', metavar='', - help='Set user password', + help=_('Set user password'), ) parser.add_argument( '--password-prompt', dest="password_prompt", action="store_true", - help='Prompt interactively for password', + help=_('Prompt interactively for password'), ) parser.add_argument( '--email', metavar='', - help='Set user email address', + help=_('Set user email address'), ) parser.add_argument( '--description', metavar='', - help='Set user description', + help=_('Set user description'), ) enable_group = parser.add_mutually_exclusive_group() enable_group.add_argument( '--enable', action='store_true', - help='Enable user (default)', + help=_('Enable user (default)'), ) enable_group.add_argument( '--disable', action='store_true', - help='Disable user', + help=_('Disable user'), ) return parser @@ -334,9 +334,8 @@ class SetUser(command.Command): and not parsed_args.description and not parsed_args.enable and not parsed_args.disable): - sys.stderr.write("Incorrect set of arguments " - "provided. See openstack --help for more " - "details\n") + sys.stderr.write(_("Incorrect set of arguments provided. " + "See openstack --help for more details\n")) return user = utils.find_resource( @@ -376,12 +375,12 @@ class SetPasswordUser(command.Command): parser.add_argument( '--password', metavar='', - help='New user password' + help=_('New user password'), ) parser.add_argument( '--original-password', metavar='', - help='Original user password' + help=_('Original user password'), ) return parser @@ -429,12 +428,12 @@ class ShowUser(command.ShowOne): parser.add_argument( 'user', metavar='', - help='User to display (name or ID)', + help=_('User to display (name or ID)'), ) parser.add_argument( '--domain', metavar='', - help='Domain owning (name or ID)', + help=_('Domain owning (name or ID)'), ) return parser