diff --git a/docs/source/conf.py b/docs/source/conf.py index c82a2344b..0362a41a1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -345,3 +345,6 @@ intersphinx_mapping = { spelling_lang='en_US' spelling_word_list_filename='spelling_wordlist.txt' + +# import before any doc is built, so _ is guaranteed to be injected +import notebook.transutils diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 97599f276..0b7c35c41 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -35,11 +35,7 @@ except ImportError: #PY2 from jinja2 import Environment, FileSystemLoader -# Set up message catalog access -base_dir = os.path.realpath(os.path.join(__file__, '..', '..')) -trans = gettext.translation('notebook', localedir=os.path.join(base_dir, 'notebook/i18n'), fallback=True) -trans.install() -_ = trans.gettext +from notebook.transutils import trans, _ # Install the pyzmq ioloop. This has to be done before anything else from # tornado is imported. diff --git a/notebook/transutils.py b/notebook/transutils.py new file mode 100644 index 000000000..1bde12e83 --- /dev/null +++ b/notebook/transutils.py @@ -0,0 +1,14 @@ +"""Translation related utilities. When imported, injects _ to builtins""" + +# Copyright (c) Jupyter Development Team. +# Distributed under the terms of the Modified BSD License. + +import os +import gettext + + +# Set up message catalog access +base_dir = os.path.realpath(os.path.join(__file__, '..', '..')) +trans = gettext.translation('notebook', localedir=os.path.join(base_dir, 'notebook/i18n'), fallback=True) +trans.install() +_ = trans.gettext