![]() |
#1 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 90
Karma: 50742
Join Date: Jan 2011
Device: PW5
|
Getting calibre's translated strings
Hi all
I've made a plugin that can be localized. The plugin shares some common strings like "Cancel", "OK" with calibre itself, which I am manually duplicating right now from the calibre-translations GitHub repo. This is not really optimal, so is there a way to gracefully fallback to or explicitly get calibre's translated strings? |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,345
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
_('OK') _('Cancel')
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 90
Karma: 50742
Join Date: Jan 2011
Device: PW5
|
This doesn't work because the plugin has possibly a different gettext domain (??).
From calibre: Code:
import gettext print( "*** (%s) gettext domain=%s, _('Cancel')=%s" % (__name__, gettext.textdomain(), _("Cancel")) ) Code:
*** (calibre.gui2) gettext domain=messages, _('Cancel')=취소 Code:
import gettext print( "*** (%s) gettext domain=%s, _('Cancel')=%s" % (__name__, gettext.textdomain(), _("Cancel")) ) Code:
*** (calibre_plugins.overdrive_libby.action) gettext domain=messages, _('Cancel')=Cancel |
![]() |
![]() |
![]() |
#4 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 90
Karma: 50742
Join Date: Jan 2011
Device: PW5
|
I was able to what I wanted by importing _ from calibre.utils.localization and not using the builtin _()
Code:
from calibre.utils.localization import _ as _c print(_c('Cancel')) |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calibre 5.13 ( Some sentences without translation (Before they were translated)) | dunhill | Calibre | 1 | 03-13-2021 09:19 PM |
Problems with translated strings | capink | Development | 5 | 03-05-2021 05:54 AM |
Translated from: which metadata for the original language of a translated book? | fxp33 | ePub | 5 | 08-12-2014 02:05 PM |
translating calibre: strings I dont understand | trijntje | Development | 7 | 08-21-2011 07:02 AM |
Is Calibre's user guide translated to any other language? | Logseman | Calibre | 1 | 10-10-2010 12:32 PM |