mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[i18n] Allow translation of some parameters in the action map
This commit is contained in:
parent
2243d3ce60
commit
735ca3af87
2 changed files with 11 additions and 3 deletions
|
@ -96,7 +96,7 @@ class AskParameter(_ExtraParameter):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Ask for the argument value
|
# Ask for the argument value
|
||||||
return msignals.prompt(message)
|
return msignals.prompt(m18n.n(message))
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
return arg_value
|
return arg_value
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class PasswordParameter(AskParameter):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Ask for the password
|
# Ask for the password
|
||||||
return msignals.prompt(message, True, True)
|
return msignals.prompt(m18n.n(message), True, True)
|
||||||
except NotImplementedError:
|
except NotImplementedError:
|
||||||
return arg_value
|
return arg_value
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ class PatternParameter(_ExtraParameter):
|
||||||
pattern, message = (arguments[0], arguments[1])
|
pattern, message = (arguments[0], arguments[1])
|
||||||
|
|
||||||
if arg_value and not re.match(pattern, arg_value or ''):
|
if arg_value and not re.match(pattern, arg_value or ''):
|
||||||
raise MoulinetteError(errno.EINVAL, message)
|
raise MoulinetteError(errno.EINVAL, m18n.n(message))
|
||||||
return arg_value
|
return arg_value
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -340,6 +340,10 @@ class ActionsMap(object):
|
||||||
with open('%s/actionsmap/%s.yml' % (pkg.datadir, n)) as f:
|
with open('%s/actionsmap/%s.yml' % (pkg.datadir, n)) as f:
|
||||||
actionsmaps[n] = yaml.load(f)
|
actionsmaps[n] = yaml.load(f)
|
||||||
|
|
||||||
|
# Load translations
|
||||||
|
# FIXME: Allow several namespaces in m18n
|
||||||
|
m18n.load_namespace(n)
|
||||||
|
|
||||||
# Generate parsers
|
# Generate parsers
|
||||||
self.extraparser = ExtraArgumentParser(parser.interface)
|
self.extraparser = ExtraArgumentParser(parser.interface)
|
||||||
self._parser = self._construct_parser(actionsmaps)
|
self._parser = self._construct_parser(actionsmaps)
|
||||||
|
|
|
@ -291,6 +291,10 @@ class BaseActionsMapParser(object):
|
||||||
"""
|
"""
|
||||||
if name == 'authenticator' and value:
|
if name == 'authenticator' and value:
|
||||||
(identifier, configuration, parameters) = value
|
(identifier, configuration, parameters) = value
|
||||||
|
# Translate help
|
||||||
|
h = configuration['help']
|
||||||
|
if h:
|
||||||
|
configuration['help'] = m18n.n(h)
|
||||||
|
|
||||||
# Return global configuration and an authenticator
|
# Return global configuration and an authenticator
|
||||||
# instanciator as a 2-tuple
|
# instanciator as a 2-tuple
|
||||||
|
|
Loading…
Reference in a new issue