|
12 | 12 | The ``guidata.configtools`` module provides configuration related tools. |
13 | 13 | """ |
14 | 14 |
|
| 15 | +import gettext |
15 | 16 | import os |
16 | 17 | import os.path as osp |
17 | 18 | import sys |
18 | | -import gettext |
19 | 19 |
|
20 | | -from guidata.utils import get_module_path, decode_fs_string |
| 20 | +from guidata.utils import decode_fs_string, get_module_path |
21 | 21 |
|
22 | 22 | IMG_PATH = [] |
23 | 23 |
|
@@ -50,9 +50,12 @@ def get_translation(modname, dirname=None): |
50 | 50 | if lang is not None: |
51 | 51 | os.environ["LANG"] = lang |
52 | 52 | try: |
53 | | - _trans = gettext.translation( |
54 | | - modname, get_module_locale_path(dirname), codeset="utf-8" |
55 | | - ) |
| 53 | + modlocpath = get_module_locale_path(dirname) |
| 54 | + try: |
| 55 | + _trans = gettext.translation(modname, modlocpath, codeset="utf-8") |
| 56 | + except TypeError: |
| 57 | + # Python >= 3.11 (codeset argument has been removed) |
| 58 | + _trans = gettext.translation(modname, modlocpath) |
56 | 59 | lgettext = _trans.gettext |
57 | 60 |
|
58 | 61 | def translate_gettext(x): |
@@ -162,8 +165,8 @@ def get_image_layout(imagename, text="", tooltip="", alignment=None): |
162 | 165 | left-aligned text [with specified tooltip] |
163 | 166 | Return (layout, label) |
164 | 167 | """ |
165 | | - from qtpy import QtWidgets as QW |
166 | 168 | from qtpy import QtCore as QC |
| 169 | + from qtpy import QtWidgets as QW |
167 | 170 |
|
168 | 171 | if alignment is None: |
169 | 172 | alignment = QC.Qt.AlignLeft |
@@ -261,8 +264,8 @@ def get_pen(conf, section, option="", color="black", width=1, style="SolidLine") |
261 | 264 | [width]: default width |
262 | 265 | [style]: default style |
263 | 266 | """ |
264 | | - from qtpy import QtGui as QG |
265 | 267 | from qtpy import QtCore as QC |
| 268 | + from qtpy import QtGui as QG |
266 | 269 |
|
267 | 270 | if "pen" not in option: |
268 | 271 | option += "/pen" |
|
0 commit comments