2019-10-22 16:24:52 +02:00
|
|
|
"""
|
2021-03-03 17:14:16 +01:00
|
|
|
Slim layer providing environment agnostic _translate()
|
2019-10-22 16:24:52 +02:00
|
|
|
"""
|
2013-06-24 21:51:01 +02:00
|
|
|
|
2018-04-16 09:00:23 +02:00
|
|
|
import state
|
2017-01-11 14:27:19 +01:00
|
|
|
|
2019-10-22 16:24:52 +02:00
|
|
|
|
2021-03-03 17:14:16 +01:00
|
|
|
def _tr_dummy(context, text, disambiguation=None, n=None):
|
2020-01-15 11:47:26 +01:00
|
|
|
# pylint: disable=unused-argument
|
2021-03-03 17:14:16 +01:00
|
|
|
return text
|
2013-06-24 21:51:01 +02:00
|
|
|
|
2019-10-22 16:24:52 +02:00
|
|
|
|
2021-03-03 17:14:16 +01:00
|
|
|
if state.enableGUI and not state.curses:
|
2017-10-07 14:50:25 +02:00
|
|
|
try:
|
2021-03-03 17:14:16 +01:00
|
|
|
from qtpy import QtWidgets, QtCore, API
|
|
|
|
except ImportError:
|
|
|
|
_translate = _tr_dummy
|
2013-06-24 21:51:01 +02:00
|
|
|
else:
|
2021-03-03 17:14:16 +01:00
|
|
|
if API == 'pyqt5':
|
|
|
|
_translate = QtWidgets.QApplication.translate
|
|
|
|
else:
|
|
|
|
def _translate(context, text, disambiguation=None, n=None):
|
|
|
|
return (
|
|
|
|
QtWidgets.QApplication.translate(
|
|
|
|
context, text, disambiguation)
|
|
|
|
if n is None else
|
|
|
|
QtWidgets.QApplication.translate(
|
|
|
|
context, text, disambiguation,
|
|
|
|
QtCore.QCoreApplication.CodecForTr, n)
|
|
|
|
)
|
|
|
|
else:
|
|
|
|
_translate = _tr_dummy
|