Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/jupyter_server/transutils.py: 73%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

11 statements  

1"""Translation related utilities. When imported, injects _ to builtins""" 

2 

3# Copyright (c) Jupyter Development Team. 

4# Distributed under the terms of the Modified BSD License. 

5import gettext 

6import os 

7import warnings 

8 

9 

10def _trans_gettext_deprecation_helper(*args, **kwargs): 

11 """The trans gettext deprecation helper.""" 

12 warn_msg = "The alias `_()` will be deprecated. Use `_i18n()` instead." 

13 warnings.warn(warn_msg, FutureWarning, stacklevel=2) 

14 return trans.gettext(*args, **kwargs) 

15 

16 

17# Set up message catalog access 

18base_dir = os.path.realpath(os.path.join(__file__, "..", "..")) 

19trans = gettext.translation( 

20 "notebook", localedir=os.path.join(base_dir, "notebook/i18n"), fallback=True 

21) 

22_ = _trans_gettext_deprecation_helper 

23_i18n = trans.gettext