Coverage for /pythoncovmergedfiles/medio/medio/src/jupyter_server/jupyter_server/transutils.py: 73%

11 statements  

« prev     ^ index     » next       coverage.py v7.3.3, created at 2023-12-15 06:13 +0000

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

2# Copyright (c) Jupyter Development Team. 

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

4import gettext 

5import os 

6import warnings 

7 

8 

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

10 """The trans gettext deprecation helper.""" 

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

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

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

14 

15 

16# Set up message catalog access 

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

18trans = gettext.translation( 

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

20) 

21_ = _trans_gettext_deprecation_helper 

22_i18n = trans.gettext