|
2 | 2 |
|
3 | 3 | # Copyright (c) Jupyter Development Team.
|
4 | 4 | # Distributed under the terms of the Modified BSD License.
|
5 |
| -import json |
6 |
| -from jupyterlab_server.translation_utils import DEFAULT_LOCALE, L10N_SCHEMA_NAME, is_valid_locale |
7 |
| -import os |
8 | 5 | from glob import glob
|
9 |
| - |
| 6 | +import json |
10 | 7 | import json5
|
11 |
| -from jsonschema import Draft4Validator as Validator |
12 |
| -from jsonschema import ValidationError |
| 8 | +from jsonschema import Draft4Validator as Validator, ValidationError |
13 | 9 | from jupyter_server.services.config.manager import ConfigManager, recursive_update
|
| 10 | +import os |
14 | 11 | from tornado import web
|
15 | 12 |
|
16 | 13 | from .server import APIHandler, tz
|
| 14 | +from .translation_utils import DEFAULT_LOCALE, L10N_SCHEMA_NAME, is_valid_locale |
17 | 15 |
|
18 | 16 | # The JupyterLab settings file extension.
|
19 | 17 | SETTINGS_EXTENSION = '.jupyterlab-settings'
|
@@ -436,14 +434,21 @@ def get_current_locale(self):
|
436 | 434 | -----
|
437 | 435 | If the locale setting is not available or not valid, it will default to jupyterlab_server.translation_utils.DEFAULT_LOCALE.
|
438 | 436 | """
|
439 |
| - settings, _ = get_settings( |
440 |
| - self.app_settings_dir, |
441 |
| - self.schemas_dir, |
442 |
| - self.settings_dir, |
443 |
| - schema_name=L10N_SCHEMA_NAME, |
444 |
| - overrides=self.overrides, |
445 |
| - labextensions_path=self.labextensions_path, |
446 |
| - ) |
| 437 | + try: |
| 438 | + settings, _ = get_settings( |
| 439 | + self.app_settings_dir, |
| 440 | + self.schemas_dir, |
| 441 | + self.settings_dir, |
| 442 | + schema_name=L10N_SCHEMA_NAME, |
| 443 | + overrides=self.overrides, |
| 444 | + labextensions_path=self.labextensions_path, |
| 445 | + ) |
| 446 | + except web.HTTPError as e: |
| 447 | + schema_warning = "Missing or misshappen translation settings schema:\n%s" |
| 448 | + self.log.warn(schema_warning % str(e)) |
| 449 | + |
| 450 | + settings = {} |
| 451 | + |
447 | 452 | current_locale = settings.get("settings", {}).get("locale", DEFAULT_LOCALE)
|
448 | 453 | if not is_valid_locale(current_locale):
|
449 | 454 | current_locale = DEFAULT_LOCALE
|
|
0 commit comments