[i18n] Use named variables in translations

This commit is contained in:
Jérôme Lebleu 2016-04-09 22:46:49 +02:00
parent 46e6e4dc7a
commit 6cfe67fb9c
5 changed files with 14 additions and 12 deletions

View file

@ -17,20 +17,20 @@
"unable_retrieve_session" : "Unable to retrieve the session",
"ldap_server_down" : "Unable to reach LDAP server",
"ldap_operation_error" : "An error occured during LDAP operation",
"ldap_attribute_already_exists" : "Attribute already exists: '{:s}={:s}'",
"ldap_attribute_already_exists" : "Attribute '{attribute}' already exists with value '{value}'",
"invalid_usage" : "Invalid usage, pass --help to see help",
"deprecated_command" : "'{prog} {old}' is deprecated and will be removed in the future, use '{prog} {new}' instead",
"argument_required" : "Argument {:s} is required",
"invalid_argument": "Invalid argument '{:s}': {:s}",
"argument_required" : "Argument '{argument}' is required",
"invalid_argument": "Invalid argument '{argument}': {error}",
"pattern_not_match": "Does not match pattern",
"password" : "Password",
"invalid_password" : "Invalid password",
"confirm" : "Confirm {:s}",
"confirm" : "Confirm {prompt}",
"values_mismatch" : "Values don't match",
"authentication_required_long" : "Authentication is required to perform this action",
"authentication_required" : "Authentication required",
"authentication_profile_required" : "Authentication to profile '{:s}' required",
"authentication_profile_required" : "Authentication to profile '{profile}' required",
"operation_interrupted" : "Operation interrupted",
"logged_in" : "Logged in",

View file

@ -163,8 +163,9 @@ class PatternParameter(_ExtraParameter):
if msg == message:
msg = m18n.g(message)
raise MoulinetteError(errno.EINVAL, m18n.g('invalid_argument',
arg_name, msg))
raise MoulinetteError(errno.EINVAL,
m18n.g('invalid_argument',
argument=arg_name, error=msg))
return arg_value
@staticmethod
@ -192,8 +193,9 @@ class RequiredParameter(_ExtraParameter):
if required and (arg_value is None or arg_value == ''):
logger.debug("argument '%s' is required",
v, arg_name, pattern)
raise MoulinetteError(errno.EINVAL, m18n.g('argument_required',
arg_name))
raise MoulinetteError(errno.EINVAL,
m18n.g('argument_required',
argument=arg_name))
return arg_value
@staticmethod

View file

@ -214,5 +214,5 @@ class Authenticator(BaseAuthenticator):
attr, value)
raise MoulinetteError(errno.EEXIST,
m18n.g('ldap_attribute_already_exists',
attr, value))
attribute=attr, value=value))
return True

View file

@ -410,7 +410,7 @@ class _ActionsMapPlugin(object):
msg = m18n.g('authentication_required')
else:
msg = m18n.g('authentication_profile_required',
authenticator.name)
profile=authenticator.name)
raise HTTPUnauthorizedResponse(msg)
else:
return authenticator(token=(s_id, s_hash))

View file

@ -393,7 +393,7 @@ class Interface(BaseInterface):
if confirm:
m = message[0].lower() + message[1:]
if prompt(m18n.g('confirm', m)) != value:
if prompt(m18n.g('confirm', prompt=m)) != value:
raise MoulinetteError(errno.EINVAL, m18n.g('values_mismatch'))
return value