mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Donate buttons should link to localized donate pages
Fixes #1819064 [Clicking on the heart (donate) button will not get you to the donate page in your language](https://bugs.launchpad.net/calibre/+bug/1819064)
This commit is contained in:
parent
94fc460f8c
commit
409aac87dd
@ -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.gui2.tweak_book.editor.insert_resource import InsertImage
|
||||||
from calibre.utils.icu import sort_key, ord_string
|
from calibre.utils.icu import sort_key, ord_string
|
||||||
from calibre.utils.unicode_names import character_name_from_code
|
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():
|
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): # {{{
|
class Central(QStackedWidget): # {{{
|
||||||
|
@ -922,7 +922,8 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
QApplication.instance().quit()
|
QApplication.instance().quit()
|
||||||
|
|
||||||
def donate(self, *args):
|
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):
|
def confirm_quit(self):
|
||||||
if self.job_manager.has_jobs():
|
if self.job_manager.has_jobs():
|
||||||
|
@ -27,7 +27,7 @@ from calibre.srv.routes import endpoint, json
|
|||||||
from calibre.srv.utils import get_library_data, get_use_roman
|
from calibre.srv.utils import get_library_data, get_use_roman
|
||||||
from calibre.utils.config import prefs, tweaks
|
from calibre.utils.config import prefs, tweaks
|
||||||
from calibre.utils.icu import sort_key, numeric_sort_key
|
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
|
from calibre.utils.search_query_parser import ParseException
|
||||||
|
|
||||||
POSTABLE = frozenset({'GET', 'POST', 'HEAD'})
|
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(),
|
'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 [],
|
'search_the_net_urls': getattr(ctx, 'search_the_net_urls', None) or [],
|
||||||
'num_per_page': rd.opts.num_per_page,
|
'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)
|
ans['library_map'], ans['default_library_id'] = ctx.library_info(rd)
|
||||||
return ans
|
return ans
|
||||||
|
@ -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 dom import set_css, clear, create_keyframes, build_rule, svgicon, add_extra_css
|
||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
from session import get_interface_data
|
||||||
|
|
||||||
bar_counter = 0
|
bar_counter = 0
|
||||||
CLASS_NAME = 'main-top-bar'
|
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 icon is 'heart':
|
||||||
if not tooltip:
|
if not tooltip:
|
||||||
tooltip = _('Donate to support calibre development')
|
tooltip = _('Donate to support calibre development')
|
||||||
|
interface_data = get_interface_data()
|
||||||
|
|
||||||
for i, bar in enumerate(bars):
|
for i, bar in enumerate(bars):
|
||||||
left = bar.firstChild
|
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'
|
animation_iteration_count='5', animation_play_state='running' if run_animation else 'paused'
|
||||||
)
|
)
|
||||||
set_css(a.firstChild, color=get_color('heart'))
|
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')
|
a.setAttribute('target', 'donate-to-calibre')
|
||||||
if action is not None:
|
if action is not None:
|
||||||
a.addEventListener('click', def(event): event.preventDefault(), action();)
|
a.addEventListener('click', def(event): event.preventDefault(), action();)
|
||||||
|
@ -170,6 +170,7 @@ default_interface_data = {
|
|||||||
'default_library_id': None,
|
'default_library_id': None,
|
||||||
'library_map': None,
|
'library_map': None,
|
||||||
'search_the_net_urls': [],
|
'search_the_net_urls': [],
|
||||||
|
'donate_link': 'https://calibre-ebook.com/donate',
|
||||||
'icon_map': {},
|
'icon_map': {},
|
||||||
'icon_path': '',
|
'icon_path': '',
|
||||||
'custom_list_template': None,
|
'custom_list_template': None,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user