forked from openlp/openlp
Noticed "No bibles available" was defined 3 times > Moved it to uistrings.
Added "Must have bibles" condition for other error messages in combined search. To do: Add a setting for controlling visibility of the no results error, it may be of annoyance. Tests...
This commit is contained in:
parent
54f720e5a2
commit
34231003ce
|
@ -23,6 +23,7 @@
|
||||||
The :mod:`uistrings` module provides standard strings for OpenLP.
|
The :mod:`uistrings` module provides standard strings for OpenLP.
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
import itertools
|
||||||
|
|
||||||
from openlp.core.common import translate
|
from openlp.core.common import translate
|
||||||
|
|
||||||
|
@ -151,23 +152,28 @@ class UiStrings(object):
|
||||||
self.Version = translate('OpenLP.Ui', 'Version')
|
self.Version = translate('OpenLP.Ui', 'Version')
|
||||||
self.View = translate('OpenLP.Ui', 'View')
|
self.View = translate('OpenLP.Ui', 'View')
|
||||||
self.ViewMode = translate('OpenLP.Ui', 'View Mode')
|
self.ViewMode = translate('OpenLP.Ui', 'View Mode')
|
||||||
|
# Translations used in both, bibles\lib\mediaitem.py and bibles\lib\manager.py
|
||||||
self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
|
self.BibleShortSearchTitle = translate('OpenLP.Ui', 'Search is Empty or too Short')
|
||||||
self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
|
self.BibleShortSearch = translate('OpenLP.Ui', '<strong>The search you have entered is empty or shorter '
|
||||||
'than 3 characters long.<br>Please try again with '
|
'than 3 characters long.<br>Please try again with '
|
||||||
'a longer search.</strong><br><br>You can separate different '
|
'a longer search.</strong><br><br>You can separate different '
|
||||||
'keywords by a space to search for all of your keywords and you '
|
'keywords by a space to search for all of your keywords and you '
|
||||||
'can separate them by a comma to search for one of them.')
|
'can separate them by a comma to search for one of them.')
|
||||||
import itertools
|
self.BibleNoBiblesTitle = translate('OpenLP.Ui', 'No Bibles Available')
|
||||||
#b = book, c = chapter, ve = verse
|
self.BibleNoBibles = translate('OpenLP.Ui', '<strong>There are no Bibles currently installed.</strong><br><br>'
|
||||||
bc = translate('OpenLP.Ui', 'Book Chapter')
|
'Please use the Import Wizard to install one or more Bibles.')
|
||||||
cha = translate('OpenLP.Ui', 'Chapter')
|
# Scripture reference error combined from small translation stings by using itertools.
|
||||||
ver = translate('OpenLP.Ui', 'Verse')
|
book_chapter = translate('OpenLP.Ui', 'Book Chapter')
|
||||||
|
bc = book_chapter
|
||||||
|
chapter = translate('OpenLP.Ui', 'Chapter')
|
||||||
|
cha = chapter
|
||||||
|
verse = translate('OpenLP.Ui', 'Verse')
|
||||||
|
ver = verse
|
||||||
interval = ' | '
|
interval = ' | '
|
||||||
psalm = translate('OpenLP.Ui', 'Psalm')
|
psalm = translate('OpenLP.Ui', 'Psalm')
|
||||||
may_shorten = translate('OpenLP.Ui', 'Book names may be shortened from full names, for an example Ps 23 = '
|
may_shorten = translate('OpenLP.Ui', 'Book names may be shortened from full names, for an example Ps 23 = '
|
||||||
'Psalm 23')
|
'Psalm 23')
|
||||||
|
bible_scripture_items = [bc, interval, psalm, ' 23<br>',
|
||||||
bible_items = [bc, interval, psalm, ' 23<br>',
|
|
||||||
bc, '%(range)s', cha, interval, psalm, ' 23%(range)s24<br>',
|
bc, '%(range)s', cha, interval, psalm, ' 23%(range)s24<br>',
|
||||||
bc, '%(verse)s', ver, '%(range)s', ver, interval, psalm, ' 23%(verse)s1%(range)s2<br>',
|
bc, '%(verse)s', ver, '%(range)s', ver, interval, psalm, ' 23%(verse)s1%(range)s2<br>',
|
||||||
bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', ver, '%(range)s', ver, interval, psalm,
|
bc, '%(verse)s', ver, '%(range)s', ver, '%(list)s', ver, '%(range)s', ver, interval, psalm,
|
||||||
|
@ -176,6 +182,8 @@ class UiStrings(object):
|
||||||
interval, psalm, ' 23%(verse)s1%(range)s2%(list)s24%(verse)s1%(range)s3<br>',
|
interval, psalm, ' 23%(verse)s1%(range)s2%(list)s24%(verse)s1%(range)s3<br>',
|
||||||
bc, '%(verse)s', ver, '%(range)s', cha, '%(verse)s', ver, interval, psalm,
|
bc, '%(verse)s', ver, '%(range)s', cha, '%(verse)s', ver, interval, psalm,
|
||||||
' 23%(verse)s1%(range)s24%(verse)s1<br><br>', may_shorten]
|
' 23%(verse)s1%(range)s24%(verse)s1<br><br>', may_shorten]
|
||||||
itertools.chain.from_iterable(itertools.repeat(x, 1) if isinstance(x, str) else x for x in bible_items)
|
itertools.chain.from_iterable(itertools.repeat(strings, 1) if isinstance(strings, str) else strings for strings
|
||||||
bible_scripture_error_all = ''.join(str(e) for e in bible_items)
|
in bible_scripture_items)
|
||||||
self.BibleScriptureError = bible_scripture_error_all
|
bible_scripture_error_joined = ''.join(str(joined) for joined in bible_scripture_items)
|
||||||
|
# This is the actual
|
||||||
|
self.BibleScriptureError = bible_scripture_error_joined
|
||||||
|
|
|
@ -262,10 +262,8 @@ class BibleManager(RegistryProperties):
|
||||||
if not bible:
|
if not bible:
|
||||||
if show_error:
|
if show_error:
|
||||||
self.main_window.information_message(
|
self.main_window.information_message(
|
||||||
translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
|
('%s' % UiStrings().BibleNoBiblesTitle),
|
||||||
translate('BiblesPlugin.BibleManager', 'There are no Bibles currently installed. Please use the '
|
('%s' % UiStrings().BibleNoBibles))
|
||||||
'Import Wizard to install one or more Bibles.')
|
|
||||||
)
|
|
||||||
return None
|
return None
|
||||||
language_selection = self.get_language_selection(bible)
|
language_selection = self.get_language_selection(bible)
|
||||||
ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id)
|
ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id)
|
||||||
|
@ -316,11 +314,8 @@ class BibleManager(RegistryProperties):
|
||||||
log.debug('BibleManager.verse_search("%s", "%s")', bible, text)
|
log.debug('BibleManager.verse_search("%s", "%s")', bible, text)
|
||||||
if not bible:
|
if not bible:
|
||||||
self.main_window.information_message(
|
self.main_window.information_message(
|
||||||
translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
|
('%s' % UiStrings().BibleNoBiblesTitle),
|
||||||
translate('BiblesPlugin.BibleManager',
|
('%s' % UiStrings().BibleNoBibles))
|
||||||
'There are no Bibles currently installed. Please use the Import Wizard to install one or '
|
|
||||||
'more Bibles.')
|
|
||||||
)
|
|
||||||
return None
|
return None
|
||||||
# Check if the bible or second_bible is a web bible.
|
# Check if the bible or second_bible is a web bible.
|
||||||
web_bible = self.db_cache[bible].get_object(BibleMeta, 'download_source')
|
web_bible = self.db_cache[bible].get_object(BibleMeta, 'download_source')
|
||||||
|
@ -345,15 +340,15 @@ class BibleManager(RegistryProperties):
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_verses_combined(self, bible, verse_text, book_ref_id=False, show_error=False):
|
def get_verses_combined(self, bible, verse_text, book_ref_id=False, show_error=True):
|
||||||
log.debug('BibleManager.get_verses("%s", "%s")', bible, verse_text)
|
log.debug('BibleManager.get_verses("%s", "%s")', bible, verse_text)
|
||||||
if not bible:
|
if not bible:
|
||||||
if show_error:
|
if show_error:
|
||||||
self.main_window.information_message(
|
if not bible:
|
||||||
translate('BiblesPlugin.BibleManager', 'No Bibles Available'),
|
self.main_window.information_message(
|
||||||
translate('BiblesPlugin.BibleManager', 'There are no Bibles currently installed. Please use the'
|
('%s' % UiStrings().BibleNoBiblesTitle),
|
||||||
' Import Wizard to install one or more Bibles.')
|
('%s' % UiStrings().BibleNoBibles))
|
||||||
)
|
return None
|
||||||
return None
|
return None
|
||||||
language_selection = self.get_language_selection(bible)
|
language_selection = self.get_language_selection(bible)
|
||||||
ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id)
|
ref_list = parse_reference(verse_text, self.db_cache[bible], language_selection, book_ref_id)
|
||||||
|
|
|
@ -660,8 +660,10 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
# This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1
|
# This will check if field has any '.' and removes them. Eg. Gen. 1 = Gen 1 = Genesis 1
|
||||||
text_direct = self.quick_search_edit.text()
|
text_direct = self.quick_search_edit.text()
|
||||||
text = text_direct.replace('. ', ' ')
|
text = text_direct.replace('. ', ' ')
|
||||||
|
# If we are doing "Reference" search, use the search from manager.py
|
||||||
if self.quick_search_edit.current_search_type() == BibleSearch.Reference:
|
if self.quick_search_edit.current_search_type() == BibleSearch.Reference:
|
||||||
self.search_results = self.plugin.manager.get_verses(bible, text)
|
self.search_results = self.plugin.manager.get_verses(bible, text)
|
||||||
|
# If we are doing "Combined Reference" search, use the get_verses_combined from manager.py (No error included)
|
||||||
else:
|
else:
|
||||||
self.search_results = self.plugin.manager.get_verses_combined(bible, text)
|
self.search_results = self.plugin.manager.get_verses_combined(bible, text)
|
||||||
if second_bible and self.search_results:
|
if second_bible and self.search_results:
|
||||||
|
@ -724,13 +726,14 @@ class BibleMediaItem(MediaManagerItem):
|
||||||
# If keyword is shorter than 3 (not including spaces), message is given and search is finalized.
|
# If keyword is shorter than 3 (not including spaces), message is given and search is finalized.
|
||||||
# It's actually to find verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if
|
# It's actually to find verses with less than 3 chars (Eg. G1 = Genesis 1) thus this error is not shown if
|
||||||
# any results are found. This check needs to be here in order to avoid duplicate errors.
|
# any results are found. This check needs to be here in order to avoid duplicate errors.
|
||||||
if not self.search_results and len(text) - text.count(' ') < 3:
|
# if no Bibles are installed, this message is not shown - "No bibles" message is whon instead. (and bible)
|
||||||
|
if not self.search_results and len(text) - text.count(' ') < 3 and bible:
|
||||||
self.main_window.information_message(
|
self.main_window.information_message(
|
||||||
('%s' % UiStrings().BibleShortSearchTitle),
|
('%s' % UiStrings().BibleShortSearchTitle),
|
||||||
('%s' % UiStrings().BibleShortSearch))
|
('%s' % UiStrings().BibleShortSearch))
|
||||||
# Text search starts here if no reference was found and keyword is longer than 2.
|
# Text search starts here if no reference was found and keyword is longer than 2.
|
||||||
# This is required in order to avoid duplicate error messages for short keywords.
|
# This is required in order to avoid duplicate error messages for short keywords.
|
||||||
if not self.search_results and len(text) - text.count(' ') > 2:
|
if not self.search_results and len(text) - text.count(' ') > 2 and bible:
|
||||||
self.on_quick_text_search()
|
self.on_quick_text_search()
|
||||||
# If no Text or Reference is found, message is given.
|
# If no Text or Reference is found, message is given.
|
||||||
if not self.search_results:
|
if not self.search_results:
|
||||||
|
|
Loading…
Reference in New Issue