[i18n] Review translations and keys related to app arguments

This commit is contained in:
Jérôme Lebleu 2015-12-28 20:10:55 +01:00
parent 096c4d0246
commit 4a06cbdc31
2 changed files with 12 additions and 10 deletions

View file

@ -29,7 +29,9 @@
"app_extraction_failed" : "Unable to extract installation files",
"app_install_files_invalid" : "Invalid installation files",
"app_manifest_invalid" : "Invalid app manifest",
"app_argument_choice_invalid" : "Invalid choice for argument '{name:s}', it must be one of {choices:s}",
"app_argument_invalid" : "Invalid value for argument '{name:s}': {error:s}",
"app_argument_missing" : "Missing argument '{:s}'",
"app_sources_fetch_failed" : "Unable to fetch sources files",
"ssowat_conf_updated" : "SSOwat persistent configuration successfully updated",
"ssowat_conf_generated" : "SSOwat configuration successfully generated",
@ -86,8 +88,6 @@
"hook_list_by_invalid" : "Invalid property to list hook by",
"hook_name_unknown" : "Unknown hook name '{:s}'",
"hook_choice_invalid" : "Invalid choice '{:s}'",
"hook_argument_missing" : "Missing argument '{:s}'",
"hook_exec_failed" : "Script execution failed",
"hook_exec_not_terminated" : "Script execution hasnt terminated",

View file

@ -1320,14 +1320,16 @@ def _parse_args_from_manifest(manifest, action, args={}, auth=None):
logger.debug("no arguments found for '%s' in '%s'", action, path)
else:
for arg in action_args:
arg_name = arg['name']
arg_value = None
# Attempt to retrieve argument value
if arg['name'] in args:
if 'choices' in arg and args[arg['name']] not in arg['choices']:
if arg_name in args:
arg_value = args[arg_name]
if 'choices' in arg and arg_value not in arg['choices']:
raise MoulinetteError(errno.EINVAL,
m18n.n('hook_choice_invalid', args[arg['name']]))
arg_value = args[arg['name']]
m18n.n('app_argument_choice_invalid',
name=arg_name, choices=', '.join(arg['choices'])))
else:
if os.isatty(1) and 'ask' in arg:
# Retrieve proper ask string
@ -1348,7 +1350,7 @@ def _parse_args_from_manifest(manifest, action, args={}, auth=None):
arg_value = arg['default']
else:
raise MoulinetteError(errno.EINVAL,
m18n.n('hook_argument_missing', arg['name']))
m18n.n('app_argument_missing', name=arg_name))
# Validate argument value
# TODO: Add more type, e.g. boolean
@ -1357,19 +1359,19 @@ def _parse_args_from_manifest(manifest, action, args={}, auth=None):
if arg_value not in domain_list(auth)['domains']:
raise MoulinetteError(errno.EINVAL,
m18n.n('app_argument_invalid',
name=arg['name'], error=m18n.n('domain_unknown')))
name=arg_name, error=m18n.n('domain_unknown')))
elif arg_type == 'user':
try:
user_info(auth, arg_value)
except MoulinetteError as e:
raise MoulinetteError(errno.EINVAL,
m18n.n('app_argument_invalid',
name=arg['name'], error=e.strerror))
name=arg_name, error=e.strerror))
elif arg_type == 'app':
if not _is_installed(arg_value):
raise MoulinetteError(errno.EINVAL,
m18n.n('app_argument_invalid',
name=arg['name'], error=m18n.n('app_unknown')))
name=arg_name, error=m18n.n('app_unknown')))
args_list.append(arg_value)
return args_list