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):
|
def install_language(language_code):
|
||||||
# globally install the _() function for the requested language
|
"""Globally install the _() function for the requested language."""
|
||||||
# fall back to a NullTranslation, which returns the English messages
|
|
||||||
language = gettext.translation(
|
language = gettext.translation(
|
||||||
'messages',
|
'messages',
|
||||||
languages=[language_code],
|
languages=[language_code],
|
||||||
localedir=LOCALE_DIR,
|
localedir=LOCALE_DIR,
|
||||||
|
# fall back to a NullTranslation, which returns the English messages
|
||||||
fallback=True)
|
fallback=True)
|
||||||
language.install()
|
language.install()
|
||||||
LOGGER.debug(f'Installed language "{language_code}"')
|
LOGGER.debug(f'Installed language "{language_code}"')
|
||||||
|
|
|
@ -17,7 +17,6 @@ from . import spec_utils
|
||||||
from .spec_utils import u
|
from .spec_utils import u
|
||||||
from . import MODEL_METADATA
|
from . import MODEL_METADATA
|
||||||
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
ARGS_SPEC = {
|
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():
|
def get_invest_models():
|
||||||
"""Gets a list of available 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:
|
Returns:
|
||||||
A JSON string
|
A JSON string
|
||||||
"""
|
"""
|
||||||
|
LOGGER.debug('get model list')
|
||||||
install_language(request.args.get('language', 'en'))
|
install_language(request.args.get('language', 'en'))
|
||||||
importlib.reload(natcap.invest)
|
importlib.reload(natcap.invest)
|
||||||
LOGGER.debug('get model list')
|
return cli.build_model_list_json()
|
||||||
a = cli.build_model_list_json()
|
|
||||||
return a
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/getspec', methods=['POST'])
|
@app.route('/getspec', methods=['POST'])
|
||||||
|
@ -65,6 +68,9 @@ def get_invest_getspec():
|
||||||
"""Gets the ARGS_SPEC dict from an InVEST model.
|
"""Gets the ARGS_SPEC dict from an InVEST model.
|
||||||
|
|
||||||
Body (JSON string): "carbon"
|
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:
|
Returns:
|
||||||
A JSON string.
|
A JSON string.
|
||||||
|
@ -86,6 +92,10 @@ def get_invest_validate():
|
||||||
model_module: string (e.g. natcap.invest.carbon)
|
model_module: string (e.g. natcap.invest.carbon)
|
||||||
args: JSON string of InVEST model args keys and values
|
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:
|
Returns:
|
||||||
A JSON string.
|
A JSON string.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue