diff --git a/src/calibre/gui2/tweak_book/ui.py b/src/calibre/gui2/tweak_book/ui.py index 0d1ad714f8..403b530f81 100644 --- a/src/calibre/gui2/tweak_book/ui.py +++ b/src/calibre/gui2/tweak_book/ui.py @@ -47,11 +47,11 @@ from calibre.gui2.tweak_book.editor.widget import register_text_editor_actions from calibre.gui2.tweak_book.editor.insert_resource import InsertImage from calibre.utils.icu import sort_key, ord_string from calibre.utils.unicode_names import character_name_from_code -from calibre.utils.localization import localize_user_manual_link +from calibre.utils.localization import localize_user_manual_link, localize_website_link def open_donate(): - open_url(QUrl('https://calibre-ebook.com/donate')) + open_url(QUrl(localize_website_link('https://calibre-ebook.com/donate'))) class Central(QStackedWidget): # {{{ diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index dd43eef419..6336a2411f 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -922,7 +922,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{ QApplication.instance().quit() def donate(self, *args): - open_url(QUrl('https://calibre-ebook.com/donate')) + from calibre.utils.localization import localize_website_link + open_url(QUrl(localize_website_link('https://calibre-ebook.com/donate'))) def confirm_quit(self): if self.job_manager.has_jobs(): diff --git a/src/calibre/srv/code.py b/src/calibre/srv/code.py index d7cfe47219..cc61d72e6e 100644 --- a/src/calibre/srv/code.py +++ b/src/calibre/srv/code.py @@ -27,7 +27,7 @@ from calibre.srv.routes import endpoint, json from calibre.srv.utils import get_library_data, get_use_roman from calibre.utils.config import prefs, tweaks from calibre.utils.icu import sort_key, numeric_sort_key -from calibre.utils.localization import get_lang, lang_map_for_ui +from calibre.utils.localization import get_lang, lang_map_for_ui, localize_website_link from calibre.utils.search_query_parser import ParseException POSTABLE = frozenset({'GET', 'POST', 'HEAD'}) @@ -150,6 +150,7 @@ def basic_interface_data(ctx, rd): 'custom_list_template': getattr(ctx, 'custom_list_template', None) or custom_list_template(), 'search_the_net_urls': getattr(ctx, 'search_the_net_urls', None) or [], 'num_per_page': rd.opts.num_per_page, + 'donate_link': localize_website_link('https://calibre-ebook.com/donate') } ans['library_map'], ans['default_library_id'] = ctx.library_info(rd) return ans diff --git a/src/pyj/book_list/top_bar.pyj b/src/pyj/book_list/top_bar.pyj index 7424ba64ba..07fe5dd8bb 100644 --- a/src/pyj/book_list/top_bar.pyj +++ b/src/pyj/book_list/top_bar.pyj @@ -6,6 +6,7 @@ from book_list.theme import get_color, get_font_size from dom import set_css, clear, create_keyframes, build_rule, svgicon, add_extra_css from elementmaker import E from gettext import gettext as _ +from session import get_interface_data bar_counter = 0 CLASS_NAME = 'main-top-bar' @@ -50,6 +51,7 @@ def set_left_data(container, title='calibre', icon='heart', action=None, tooltip if icon is 'heart': if not tooltip: tooltip = _('Donate to support calibre development') + interface_data = get_interface_data() for i, bar in enumerate(bars): left = bar.firstChild @@ -66,7 +68,7 @@ def set_left_data(container, title='calibre', icon='heart', action=None, tooltip animation_iteration_count='5', animation_play_state='running' if run_animation else 'paused' ) set_css(a.firstChild, color=get_color('heart')) - a.setAttribute('href', 'https://calibre-ebook.com/donate') + a.setAttribute('href', interface_data.donate_link) a.setAttribute('target', 'donate-to-calibre') if action is not None: a.addEventListener('click', def(event): event.preventDefault(), action();) diff --git a/src/pyj/session.pyj b/src/pyj/session.pyj index cc8c8cbd68..d8c25a781c 100644 --- a/src/pyj/session.pyj +++ b/src/pyj/session.pyj @@ -170,6 +170,7 @@ default_interface_data = { 'default_library_id': None, 'library_map': None, 'search_the_net_urls': [], + 'donate_link': 'https://calibre-ebook.com/donate', 'icon_map': {}, 'icon_path': '', 'custom_list_template': None,