mirror of
https://github.com/readest/readest.git
synced 2026-11-30 11:49:50 +00:00
* feat(calibre): add multi-language support * fix(calibre): harden the translation build and pluralize the run summary - i18n.py compile: validate placeholders in every plural form, skip fuzzy and empty translations (gettext would show them blank), and write no .mo for a catalog with errors so make fails again instead of shipping it. Missing messages only warn; calibre shows them in English. - Makefile: derive the .mo list from the .po files so a new language is built and zipped, and compile only the stale language. - worker: give each status its own ngettext summary message, restoring the lowercase English summary and letting translators handle agreement. - api: translate the fallback error messages; oauth: escape translated text in the login pages. - pl: use the Polish plural rule; ru: genitive after "Отправка"/"Сверка"; status labels capitalized where they now only fill the table column. - README: list the languages that actually ship. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Huang Xin <chrox.huang@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
1.9 KiB
Python
55 lines
1.9 KiB
Python
__license__ = 'AGPL v3'
|
|
__copyright__ = '2026, Bilingify LLC'
|
|
|
|
from calibre.utils.config import JSONConfig
|
|
from qt.core import QCheckBox, QLabel, QLineEdit, QVBoxLayout, QWidget
|
|
|
|
from calibre_plugins.readest.api import DEFAULT_API_BASE, DEFAULT_SUPABASE_URL
|
|
|
|
try:
|
|
load_translations()
|
|
except NameError:
|
|
pass
|
|
|
|
prefs = JSONConfig('plugins/readest')
|
|
|
|
prefs.defaults['api_base'] = DEFAULT_API_BASE
|
|
prefs.defaults['supabase_url'] = DEFAULT_SUPABASE_URL
|
|
prefs.defaults['tokens'] = None # {access_token, refresh_token, expires_at, expires_in}
|
|
prefs.defaults['user_email'] = None
|
|
prefs.defaults['include_custom_columns'] = True
|
|
|
|
|
|
def save_tokens(tokens):
|
|
prefs['tokens'] = tokens
|
|
if tokens is None:
|
|
prefs['user_email'] = None
|
|
|
|
|
|
class ConfigWidget(QWidget):
|
|
def __init__(self):
|
|
QWidget.__init__(self)
|
|
layout = QVBoxLayout()
|
|
self.setLayout(layout)
|
|
|
|
account = prefs['user_email']
|
|
status = (_('Logged in as %s.') % account) if account else _('Not logged in.')
|
|
layout.addWidget(QLabel(status + ' ' + _('Use the Readest toolbar menu to log in or out.')))
|
|
|
|
self.custom_columns_checkbox = QCheckBox(_('Include custom columns in pushed metadata'))
|
|
self.custom_columns_checkbox.setChecked(bool(prefs['include_custom_columns']))
|
|
layout.addWidget(self.custom_columns_checkbox)
|
|
|
|
layout.addWidget(QLabel(_('API server:')))
|
|
self.api_base_edit = QLineEdit(self)
|
|
self.api_base_edit.setText(prefs['api_base'])
|
|
self.api_base_edit.setToolTip(
|
|
_('Only change this if you run a self-hosted Readest server.')
|
|
)
|
|
layout.addWidget(self.api_base_edit)
|
|
|
|
layout.addStretch()
|
|
|
|
def save_settings(self):
|
|
prefs['include_custom_columns'] = self.custom_columns_checkbox.isChecked()
|
|
prefs['api_base'] = self.api_base_edit.text().strip() or DEFAULT_API_BASE
|