Fix i18n problems for common files in identity

Some missing parts in identity.

Change-Id: I8777b845613d7d7df36ac3c198da552e11aaad1b
Partial-bug: #1574965
This commit is contained in:
Tang Chen 2016-06-13 16:44:21 +08:00
parent e5e29a8fef
commit 304f565439
2 changed files with 22 additions and 20 deletions

View File

@ -19,6 +19,7 @@ from keystoneclient.v2_0 import client as identity_client_v2
from osc_lib import utils from osc_lib import utils
from openstackclient.api import auth from openstackclient.api import auth
from openstackclient.i18n import _
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -65,9 +66,9 @@ def build_option_parser(parser):
'--os-identity-api-version', '--os-identity-api-version',
metavar='<identity-api-version>', metavar='<identity-api-version>',
default=utils.env('OS_IDENTITY_API_VERSION'), default=utils.env('OS_IDENTITY_API_VERSION'),
help='Identity API version, default=' + help=_('Identity API version, default=%s '
DEFAULT_API_VERSION + '(Env: OS_IDENTITY_API_VERSION)') % DEFAULT_API_VERSION,
' (Env: OS_IDENTITY_API_VERSION)') )
return auth.build_auth_plugins_option_parser(parser) return auth.build_auth_plugins_option_parser(parser)

View File

@ -23,6 +23,8 @@ from keystoneclient.v3 import users
from osc_lib import exceptions from osc_lib import exceptions
from osc_lib import utils from osc_lib import utils
from openstackclient.i18n import _
def find_service(identity_client, name_type_or_id): def find_service(identity_client, name_type_or_id):
"""Find a service by id, name or type.""" """Find a service by id, name or type."""
@ -37,14 +39,12 @@ def find_service(identity_client, name_type_or_id):
# FIXME(dtroyer): This exception should eventually come from # FIXME(dtroyer): This exception should eventually come from
# common client exceptions # common client exceptions
except identity_exc.NotFound: except identity_exc.NotFound:
msg = ("No service with a type, name or ID of '%s' exists." msg = _("No service with a type, name or ID of '%s' exists.")
% name_type_or_id) raise exceptions.CommandError(msg % name_type_or_id)
raise exceptions.CommandError(msg)
except identity_exc.NoUniqueMatch: except identity_exc.NoUniqueMatch:
msg = ("Multiple service matches found for '%s', " msg = _("Multiple service matches found for '%s', "
"use an ID to be more specific." "use an ID to be more specific.")
% name_type_or_id) raise exceptions.CommandError(msg % name_type_or_id)
raise exceptions.CommandError(msg)
def _get_domain_id_if_requested(identity_client, domain_name_or_id): def _get_domain_id_if_requested(identity_client, domain_name_or_id):
@ -131,9 +131,9 @@ def add_user_domain_option_to_parser(parser):
parser.add_argument( parser.add_argument(
'--user-domain', '--user-domain',
metavar='<user-domain>', metavar='<user-domain>',
help=('Domain the user belongs to (name or ID). ' help=_('Domain the user belongs to (name or ID). '
'This can be used in case collisions between user names ' 'This can be used in case collisions between user names '
'exist.') 'exist.'),
) )
@ -141,9 +141,9 @@ def add_group_domain_option_to_parser(parser):
parser.add_argument( parser.add_argument(
'--group-domain', '--group-domain',
metavar='<group-domain>', metavar='<group-domain>',
help=('Domain the group belongs to (name or ID). ' help=_('Domain the group belongs to (name or ID). '
'This can be used in case collisions between group names ' 'This can be used in case collisions between group names '
'exist.') 'exist.'),
) )
@ -151,9 +151,9 @@ def add_project_domain_option_to_parser(parser):
parser.add_argument( parser.add_argument(
'--project-domain', '--project-domain',
metavar='<project-domain>', metavar='<project-domain>',
help=('Domain the project belongs to (name or ID). ' help=_('Domain the project belongs to (name or ID). '
'This can be used in case collisions between project names ' 'This can be used in case collisions between project names '
'exist.') 'exist.'),
) )
@ -162,5 +162,6 @@ def add_inherited_option_to_parser(parser):
'--inherited', '--inherited',
action='store_true', action='store_true',
default=False, default=False,
help=('Specifies if the role grant is inheritable to the sub projects') help=_('Specifies if the role grant is inheritable to the sub '
'projects'),
) )