View Single Post
Old 08-07-2025, 10:29 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,621
Karma: 28549046
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Those are all functions that were defined as globals in calibre a long time ago. _ and gettext and ngettext can now be imported perfectly safely. If you are worried about doing so for compat reasons you can do the following:

Code:
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    from calibre.utils.localization import ...
else:
    the original code
This should work with all type checkers. As for load_translations() that's specific to calibre plugins and is documented in the manual https://manual.calibre-ebook.com/creating_plugins.html
kovidgoyal is offline   Reply With Quote