Keeps an optional translate callable; _tr(text) applies it.
Classes using it implement retranslate() to re-show their labels.
Source code in src/cutepandas/utils/i18n.py
| class TranslateMixin:
"""Keeps an optional `translate` callable; `_tr(text)` applies it.
Classes using it implement `retranslate()` to re-show their labels.
"""
_translate: Translate | None = None
def _tr(self, text: str) -> str:
return text if self._translate is None else self._translate(text)
def set_translate(self, translate: Translate | None):
"""Use another translate callable (None: English) and re-show the labels."""
self._translate = translate
self.retranslate()
def get_translate(self) -> Translate | None:
return self._translate
def retranslate(self):
"""Re-show the labels (after the translate callable changed its language)."""
|
retranslate
Re-show the labels (after the translate callable changed its language).
Source code in src/cutepandas/utils/i18n.py
| def retranslate(self):
"""Re-show the labels (after the translate callable changed its language)."""
|
set_translate
set_translate(translate: Translate | None)
Use another translate callable (None: English) and re-show the labels.
Source code in src/cutepandas/utils/i18n.py
| def set_translate(self, translate: Translate | None):
"""Use another translate callable (None: English) and re-show the labels."""
self._translate = translate
self.retranslate()
|