clean up, update message catalogs

This commit is contained in:
emlys 2021-11-12 12:56:31 -08:00
parent fca3a56f9a
commit 1d7689cda4
6 changed files with 4537 additions and 566 deletions

View File

@ -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}"')

View File

@ -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

View File

@ -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.
"""