clean up, update message catalogs
This commit is contained in:
parent
fca3a56f9a
commit
1d7689cda4
|
@ -217,12 +217,12 @@ MODEL_METADATA = {
|
|||
|
||||
|
||||
def install_language(language_code):
|
||||
# globally install the _() function for the requested language
|
||||
# fall back to a NullTranslation, which returns the English messages
|
||||
"""Globally install the _() function for the requested language."""
|
||||
language = gettext.translation(
|
||||
'messages',
|
||||
languages=[language_code],
|
||||
localedir=LOCALE_DIR,
|
||||
# fall back to a NullTranslation, which returns the English messages
|
||||
fallback=True)
|
||||
language.install()
|
||||
LOGGER.debug(f'Installed language "{language_code}"')
|
||||
|
|
|
@ -17,7 +17,6 @@ from . import spec_utils
|
|||
from .spec_utils import u
|
||||
from . import MODEL_METADATA
|
||||
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
ARGS_SPEC = {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -50,14 +50,17 @@ def shutdown():
|
|||
def get_invest_models():
|
||||
"""Gets a list of available InVEST models.
|
||||
|
||||
Accepts a `language` query parameter which should be an ISO 639-1 language
|
||||
code. Model names will be translated to the requested language if
|
||||
translations are available, or fall back to English otherwise.
|
||||
|
||||
Returns:
|
||||
A JSON string
|
||||
"""
|
||||
LOGGER.debug('get model list')
|
||||
install_language(request.args.get('language', 'en'))
|
||||
importlib.reload(natcap.invest)
|
||||
LOGGER.debug('get model list')
|
||||
a = cli.build_model_list_json()
|
||||
return a
|
||||
return cli.build_model_list_json()
|
||||
|
||||
|
||||
@app.route('/getspec', methods=['POST'])
|
||||
|
@ -65,6 +68,9 @@ def get_invest_getspec():
|
|||
"""Gets the ARGS_SPEC dict from an InVEST model.
|
||||
|
||||
Body (JSON string): "carbon"
|
||||
Accepts a `language` query parameter which should be an ISO 639-1 language
|
||||
code. Spec 'about' and 'name' values will be translated to the requested
|
||||
language if translations are available, or fall back to English otherwise.
|
||||
|
||||
Returns:
|
||||
A JSON string.
|
||||
|
@ -86,6 +92,10 @@ def get_invest_validate():
|
|||
model_module: string (e.g. natcap.invest.carbon)
|
||||
args: JSON string of InVEST model args keys and values
|
||||
|
||||
Accepts a `language` query parameter which should be an ISO 639-1 language
|
||||
code. Validation messages will be translated to the requested language if
|
||||
translations are available, or fall back to English otherwise.
|
||||
|
||||
Returns:
|
||||
A JSON string.
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue