diff --git a/docs/goodtoknow.rst b/docs/goodtoknow.rst index 6314b133..14682126 100644 --- a/docs/goodtoknow.rst +++ b/docs/goodtoknow.rst @@ -62,6 +62,8 @@ Which can also be activated in the code using :py:func:`xclim.core.options.set_o Translation is of course not automatic but relies on manually populated `gettext `_ catalogs. xscen ships with a catalog of french (fr) translations. See :ref:`translating-xscen` to learn how to add translations to xscen. xclim's documentation of the same subject is `here `_. +If your xscen is installed in "editable" mode in its source directory (``pip install -e .``), you should run ``make translate`` each time you pull changes from the upstream source. + Module-wide options ------------------- diff --git a/xscen/utils.py b/xscen/utils.py index c7d931a8..ff19854c 100644 --- a/xscen/utils.py +++ b/xscen/utils.py @@ -55,12 +55,16 @@ If a language is not defined or a message not translated, the function will return the raw message. """ - -for loc in (Path(__file__).parent / "data").iterdir(): - if loc.is_dir() and len(loc.name) == 2: - TRANSLATOR[loc.name] = gettext.translation( - "xscen", localedir=loc.parent, languages=[loc.name] - ).gettext +try: + for loc in (Path(__file__).parent / "data").iterdir(): + if loc.is_dir() and len(loc.name) == 2: + TRANSLATOR[loc.name] = gettext.translation( + "xscen", localedir=loc.parent, languages=[loc.name] + ).gettext +except FileNotFoundError as err: + raise ImportError( + "Your xscen installation doesn't have compiled translations. Run `make translate` from the source directory to fix." + ) from err def update_attr(ds, attr, new, others=None, **fmt):