Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 07-16-2023, 08:51 PM   #1
modified
Connoisseur
modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
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?
modified is offline   Reply With Quote
Old 07-16-2023, 09:30 PM   #2
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: 43,866
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
_('OK') _('Cancel')
kovidgoyal is offline   Reply With Quote
Advert
Old 07-16-2023, 11:46 PM   #3
modified
Connoisseur
modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
Posts: 90
Karma: 50742
Join Date: Jan 2011
Device: PW5
Quote:
Originally Posted by kovidgoyal View Post
_('OK') _('Cancel')
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')=취소
From plugin that is localized:
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
modified is offline   Reply With Quote
Old 07-17-2023, 01:18 AM   #4
modified
Connoisseur
modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!modified is faster than a rolling 'o,' stronger than silent 'e,' and leaps capital 'T' in a single bound!
 
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'))
modified is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 05:39 PM.


MobileRead.com is a privately owned, operated and funded community.