File: transutils.py

package info (click to toggle)
jupyter-server 2.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,068 kB
  • sloc: python: 21,064; makefile: 186; sh: 25; javascript: 14
file content (23 lines) | stat: -rw-r--r-- 768 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"""Translation related utilities. When imported, injects _ to builtins"""

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
import gettext
import os
import warnings


def _trans_gettext_deprecation_helper(*args, **kwargs):
    """The trans gettext deprecation helper."""
    warn_msg = "The alias `_()` will be deprecated. Use `_i18n()` instead."
    warnings.warn(warn_msg, FutureWarning, stacklevel=2)
    return trans.gettext(*args, **kwargs)


# 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_gettext_deprecation_helper
_i18n = trans.gettext