From 3ed9dcaae3301d85673be03f700f6860f1c5f6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 29 Feb 2012 12:47:21 +0100 Subject: [PATCH 1/6] add possibility to switch the booknames of bibles - fix bug #822363 --- openlp/plugins/bibles/lib/__init__.py | 7 ++ openlp/plugins/bibles/lib/biblestab.py | 50 +++++++++- openlp/plugins/bibles/lib/manager.py | 13 +++ openlp/plugins/bibles/lib/mediaitem.py | 56 ++++++++++-- openlp/plugins/bibles/lib/ui.py | 121 +++++++++++++++++++++++++ 5 files changed, 235 insertions(+), 12 deletions(-) create mode 100644 openlp/plugins/bibles/lib/ui.py diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 6189f108f..e9e6ad5d3 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -58,6 +58,13 @@ class DisplayStyle(object): Curly = 2 Square = 3 +class LanguageSelection(object): + """ + An enumeration for bible bookname language. + """ + Bible = 0 + Application = 1 + English = 2 def update_reference_separators(): """ diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index e8e0d9e2c..c7028b577 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -32,7 +32,7 @@ from PyQt4 import QtCore, QtGui from openlp.core.lib import Receiver, SettingsTab, translate from openlp.core.lib.ui import UiStrings, find_and_set_in_combo_box from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ - update_reference_separators, get_reference_separator + update_reference_separators, get_reference_separator, LanguageSelection log = logging.getLogger(__name__) @@ -140,9 +140,25 @@ class BiblesTab(SettingsTab): self.scriptureReferenceLayout.addWidget(self.endSeparatorLineEdit, 3, 1) self.leftLayout.addWidget(self.scriptureReferenceGroupBox) - self.leftLayout.addStretch() self.rightColumn.setSizePolicy( QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred) + self.languageSelectionGroupBox = QtGui.QGroupBox(self.rightColumn) + self.languageSelectionGroupBox.setObjectName( + u'languageSelectionGroupBox') + self.languageSelectionLayout = QtGui.QVBoxLayout( + self.languageSelectionGroupBox) + self.languageSelectionLabel = QtGui.QLabel( + self.languageSelectionGroupBox) + self.languageSelectionLabel.setObjectName(u'languageSelectionLabel') + self.languageSelectionComboBox = QtGui.QComboBox( + self.languageSelectionGroupBox) + self.languageSelectionComboBox.setObjectName( + u'languageSelectionComboBox') + self.languageSelectionComboBox.addItems([u'', u'', u'']) + self.languageSelectionLayout.addWidget(self.languageSelectionLabel) + self.languageSelectionLayout.addWidget(self.languageSelectionComboBox) + self.rightLayout.addWidget(self.languageSelectionGroupBox) + self.leftLayout.addStretch() self.rightLayout.addStretch() # Signals and slots QtCore.QObject.connect( @@ -198,6 +214,9 @@ class BiblesTab(SettingsTab): self.onEndSeparatorLineEditFinished) QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'theme_update_list'), self.updateThemeList) + QtCore.QObject.connect( + self.languageSelectionComboBox, QtCore.SIGNAL(u'activated(int)'), + self.onLanguageSelectionComboBoxChanged) def retranslateUi(self): self.verseDisplayGroupBox.setTitle( @@ -257,6 +276,24 @@ class BiblesTab(SettingsTab): 'end marks may be defined.\nThey have to be separated by a ' 'vertical bar "|".\nPlease clear this edit line to use the ' 'default value.')) + self.languageSelectionGroupBox.setTitle( + translate('BiblesPlugin.BiblesTab', 'Preferred Bookname Language')) + self.languageSelectionLabel.setText(translate('BiblesPlugin.BiblesTab', + 'Choose the language in which the book names of the\nbible should ' + 'be displayed in advanced search or on\nautocompleter in quick ' + 'search:')) + self.languageSelectionComboBox.setItemText(LanguageSelection.Bible, + translate('BiblesPlugin.BiblesTab', 'Bible language')) + self.languageSelectionComboBox.setItemText( + LanguageSelection.Application, + translate('BiblesPlugin.BiblesTab', 'Application language')) + self.languageSelectionComboBox.setItemText(LanguageSelection.English, + translate('BiblesPlugin.BiblesTab', 'English')) + self.languageSelectionComboBox.setToolTip( + translate('BiblesPlugin.BiblesTab', 'Multiple options:\n ' + 'Bible language - the language in which the bible book names ' + 'was imported\n Application language - the language you have ' + 'choosen for Openlp\n English - use always English booknames')) def onBibleThemeComboBoxChanged(self): self.bible_theme = self.bibleThemeComboBox.currentText() @@ -267,6 +304,9 @@ class BiblesTab(SettingsTab): def onLayoutStyleComboBoxChanged(self): self.layout_style = self.layoutStyleComboBox.currentIndex() + def onLanguageSelectionComboBoxChanged(self): + self.language_selection = self.languageSelectionComboBox.currentIndex() + def onNewChaptersCheckBoxChanged(self, check_state): self.show_new_chapters = False # We have a set value convert to True/False. @@ -448,6 +488,9 @@ class BiblesTab(SettingsTab): self.endSeparatorLineEdit.setPalette( self.getGreyTextPalette(False)) self.endSeparatorCheckBox.setChecked(True) + self.language_selection = settings.value( + u'bookname language', QtCore.QVariant(0)).toInt()[0] + self.languageSelectionComboBox.setCurrentIndex(self.language_selection) settings.endGroup() def save(self): @@ -459,6 +502,8 @@ class BiblesTab(SettingsTab): QtCore.QVariant(self.display_style)) settings.setValue(u'verse layout style', QtCore.QVariant(self.layout_style)) + settings.setValue(u'bookname language', + QtCore.QVariant(self.language_selection)) settings.setValue(u'second bibles', QtCore.QVariant(self.second_bibles)) settings.setValue(u'bible theme', QtCore.QVariant(self.bible_theme)) if self.verseSeparatorCheckBox.isChecked(): @@ -482,6 +527,7 @@ class BiblesTab(SettingsTab): else: settings.remove(u'end separator') update_reference_separators() + Receiver.send_message(u'bibles_load_list') settings.endGroup() def updateThemeList(self, theme_list): diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index c231f2062..411e25367 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -227,6 +227,19 @@ class BibleManager(object): for book in self.db_cache[bible].get_books() ] + def get_book_by_id(self, bible, id): + """ + Returns a book object by given id. + + ``bible`` + Unicode. The Bible to get the list of books from. + + ``id`` + Unicode. The book_reference_id to get the book for. + """ + log.debug(u'BibleManager.get_book_by_id("%s", "%s")', bible, id) + return self.db_cache[bible].get_book_by_book_ref_id(id) + def get_chapter_count(self, bible, book): """ Returns the number of Chapters for a given book. diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 29172a334..50872aef3 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -38,7 +38,9 @@ from openlp.core.lib.ui import UiStrings, add_widget_completer, \ find_and_set_in_combo_box, build_icon from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ - VerseReferenceList, get_reference_separator + VerseReferenceList, get_reference_separator, LanguageSelection +from openlp.plugins.bibles.lib.ui import BibleStrings +from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -424,20 +426,37 @@ class BibleMediaItem(MediaManagerItem): book_data = book_data_temp self.advancedBookComboBox.clear() first = True + language_selection = QtCore.QSettings().value( + self.settingsSection + u'/bookname language', + QtCore.QVariant(0)).toInt()[0] for book in book_data: row = self.advancedBookComboBox.count() - self.advancedBookComboBox.addItem(book[u'name']) + if language_selection == LanguageSelection.Bible: + self.advancedBookComboBox.addItem(book[u'name']) + elif language_selection == LanguageSelection.Application: + data = BiblesResourcesDB.get_book_by_id( + book[u'book_reference_id']) + abbr = data[u'abbreviation'].replace(u'1', u'First').\ + replace(u'2', u'Second').replace(u'3', u'Third').\ + replace(u'4', u'Fourth') + self.advancedBookComboBox.addItem(getattr(BibleStrings, abbr)) + elif language_selection == LanguageSelection.English: + data = BiblesResourcesDB.get_book_by_id( + book[u'book_reference_id']) + self.advancedBookComboBox.addItem(data[u'name']) self.advancedBookComboBox.setItemData( - row, QtCore.QVariant(book[u'chapters'])) + row, QtCore.QVariant(book[u'book_reference_id'])) if first: first = False self.initialiseChapterVerse(bible, book[u'name'], - book[u'chapters']) + book[u'book_reference_id']) - def initialiseChapterVerse(self, bible, book, chapter_count): - log.debug(u'initialiseChapterVerse %s, %s', bible, book) - self.chapter_count = chapter_count - verse_count = self.plugin.manager.get_verse_count(bible, book, 1) + def initialiseChapterVerse(self, bible, book, book_ref_id): + log.debug(u'initialiseChapterVerse %s, %s, %s', bible, book, + book_ref_id) + book = self.plugin.manager.get_book_by_id(bible, book_ref_id) + self.chapter_count = self.plugin.manager.get_chapter_count(bible, book) + verse_count = self.plugin.manager.get_verse_count(bible, book.name, 1) if verse_count == 0: self.advancedSearchButton.setEnabled(False) critical_error_message_box( @@ -480,7 +499,24 @@ class BibleMediaItem(MediaManagerItem): secondbook.book_reference_id: book_data_temp.append(book) book_data = book_data_temp - books = [book.name + u' ' for book in book_data] + language_selection = QtCore.QSettings().value( + self.settingsSection + u'/bookname language', + QtCore.QVariant(0)).toInt()[0] + if language_selection == LanguageSelection.Bible: + books = [book.name + u' ' for book in book_data] + elif language_selection == LanguageSelection.Application: + for book in book_data: + data = BiblesResourcesDB.get_book_by_id( + book.book_reference_id) + abbr = data[u'abbreviation'].replace(u'1', u'First').\ + replace(u'2', u'Second').replace(u'3', u'Third').\ + replace(u'4', u'Fourth') + books.append(getattr(BibleStrings, abbr) + u' ') + elif language_selection == LanguageSelection.English: + for book in book_data: + data = BiblesResourcesDB.get_book_by_id( + book.book_reference_id) + books.append(data[u'name'] + u' ') books.sort(cmp=locale.strcoll) add_widget_completer(books, self.quickSearchEdit) @@ -547,7 +583,7 @@ class BibleMediaItem(MediaManagerItem): self.initialiseChapterVerse( unicode(self.advancedVersionComboBox.currentText()), unicode(self.advancedBookComboBox.currentText()), - self.advancedBookComboBox.itemData(item).toInt()[0]) + unicode(self.advancedBookComboBox.itemData(item).toString())) def onAdvancedFromVerse(self): chapter_from = int(self.advancedFromChapter.currentText()) diff --git a/openlp/plugins/bibles/lib/ui.py b/openlp/plugins/bibles/lib/ui.py new file mode 100644 index 000000000..ca9c35785 --- /dev/null +++ b/openlp/plugins/bibles/lib/ui.py @@ -0,0 +1,121 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) Second008-2012 Raoul Snyman # +# Portions copyright (c) Second008-2012 Tim Bentley, Gerald Britton, Jonathan # +# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # +# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # +# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # +# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version Second of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### +""" +The :mod:`openlp.plugins.bibles.lib.ui` module provides standard UI components +for the bibles plugin. +""" +from openlp.core.lib import translate + +class BibleStrings(object): + """ + Provide standard strings for use throughout the bibles plugin. + """ + # These strings should need a good reason to be retranslated elsewhere. + Gen = translate('OpenLP.Ui','Genesis') + Exod = translate('OpenLP.Ui','Exodus') + Lev = translate('OpenLP.Ui','Leviticus') + Num = translate('OpenLP.Ui','Numbers') + Deut = translate('OpenLP.Ui','Deuteronomy') + Josh = translate('OpenLP.Ui','Joshua') + Judg = translate('OpenLP.Ui','Judges') + Ruth = translate('OpenLP.Ui','Ruth') + FirstSam = translate('OpenLP.Ui','1 Samuel') + SecondSam = translate('OpenLP.Ui','2 Samuel') + FirstKgs = translate('OpenLP.Ui','1 Kings') + SecondKgs = translate('OpenLP.Ui','2 Kings') + FirstChr = translate('OpenLP.Ui','1 Chronicles') + SecondChr = translate('OpenLP.Ui','2 Chronicles') + Esra = translate('OpenLP.Ui','Ezra') + Neh = translate('OpenLP.Ui','Nehemiah') + Esth = translate('OpenLP.Ui','Esther') + Job = translate('OpenLP.Ui','Job') + Ps = translate('OpenLP.Ui','Psalms') + Prov = translate('OpenLP.Ui','Proverbs') + Eccl = translate('OpenLP.Ui','Ecclesiastes') + Song = translate('OpenLP.Ui','Song of Solomon') + Isa = translate('OpenLP.Ui','Isaiah') + Jer = translate('OpenLP.Ui','Jeremiah') + Lam = translate('OpenLP.Ui','Lamentations') + Ezek = translate('OpenLP.Ui','Ezekiel') + Dan = translate('OpenLP.Ui','Daniel') + Hos = translate('OpenLP.Ui','Hosea') + Joel = translate('OpenLP.Ui','Joel') + Amos= translate('OpenLP.Ui','Amos') + Obad = translate('OpenLP.Ui','Obadiah') + Jonah = translate('OpenLP.Ui','Jonah') + Mic = translate('OpenLP.Ui','Micah') + Nah = translate('OpenLP.Ui','Nahum') + Hab = translate('OpenLP.Ui','Habakkuk') + Zeph = translate('OpenLP.Ui','Zephaniah') + Hag = translate('OpenLP.Ui','Haggai') + Zech = translate('OpenLP.Ui','Zechariah') + Mal = translate('OpenLP.Ui','Malachi') + Matt = translate('OpenLP.Ui','Matthew') + Mark = translate('OpenLP.Ui','Mark') + Luke = translate('OpenLP.Ui','Luke') + John = translate('OpenLP.Ui','John') + Acts = translate('OpenLP.Ui','Acts') + Rom = translate('OpenLP.Ui','Romans') + FirstCor = translate('OpenLP.Ui','1 Corinthians') + SecondCor = translate('OpenLP.Ui','2 Corinthians') + Gal = translate('OpenLP.Ui','Galatians') + Eph = translate('OpenLP.Ui','Ephesians') + Phil = translate('OpenLP.Ui','Philippians') + Col = translate('OpenLP.Ui','Colossians') + FirstThess = translate('OpenLP.Ui','1 Thessalonians') + SecondThess = translate('OpenLP.Ui','2 Thessalonians') + FirstTim = translate('OpenLP.Ui','1 Timothy') + SecondTim = translate('OpenLP.Ui','2 Timothy') + Titus = translate('OpenLP.Ui','Titus') + Phlm = translate('OpenLP.Ui','Philemon') + Heb = translate('OpenLP.Ui','Hebrews') + Jas = translate('OpenLP.Ui','James') + FirstPet = translate('OpenLP.Ui','1 Peter') + SecondPet = translate('OpenLP.Ui','2 Peter') + FirstJohn = translate('OpenLP.Ui','1 John') + SecondJohn = translate('OpenLP.Ui','2 John') + ThirdJohn = translate('OpenLP.Ui','3 John') + Jude = translate('OpenLP.Ui','Jude') + Rev = translate('OpenLP.Ui','Revelation') + Jdt = translate('OpenLP.Ui','Judith') + Wis = translate('OpenLP.Ui','Wisdom') + Tob = translate('OpenLP.Ui','Tobit') + Sir = translate('OpenLP.Ui','Sirach') + Bar = translate('OpenLP.Ui','Baruch') + FirstMacc = translate('OpenLP.Ui','1 Maccabees') + SecondMacc = translate('OpenLP.Ui','2 Maccabees') + ThirdMacc = translate('OpenLP.Ui','3 Maccabees') + FourthMacc = translate('OpenLP.Ui','4 Maccabees') + AddDan = translate('OpenLP.Ui','Rest of Daniel') + AddEsth = translate('OpenLP.Ui','Rest of Esther') + PrMan = translate('OpenLP.Ui','Prayer of Manasses') + LetJer = translate('OpenLP.Ui','Letter of Jeremiah') + PrAza = translate('OpenLP.Ui','Prayer of Azariah') + Sus = translate('OpenLP.Ui','Susanna') + Bel = translate('OpenLP.Ui','Bel') + FirstEsdr = translate('OpenLP.Ui','1 Esdras') + SecondEsdr = translate('OpenLP.Ui','2 Esdras') From 371e624ea237e661b43873246b9097ba94f11906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 4 Mar 2012 21:10:17 +0100 Subject: [PATCH 2/6] improve possibility to switch booknames - fix some bugs - move translation string to a dict --- openlp/plugins/bibles/lib/__init__.py | 155 +++++++++++++++++++++++-- openlp/plugins/bibles/lib/db.py | 61 +++++++--- openlp/plugins/bibles/lib/manager.py | 46 ++++---- openlp/plugins/bibles/lib/mediaitem.py | 55 +++++---- 4 files changed, 244 insertions(+), 73 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index e9e6ad5d3..51d7f483a 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -34,6 +34,7 @@ import re from PyQt4 import QtCore from openlp.core.lib import translate +from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -61,10 +62,98 @@ class DisplayStyle(object): class LanguageSelection(object): """ An enumeration for bible bookname language. + And standard strings for use throughout the bibles plugin. """ Bible = 0 Application = 1 English = 2 + + Booknames = { + u'Gen': translate('BiblesPlugin','Genesis'), + u'Exod': translate('BiblesPlugin','Exodus'), + u'Lev': translate('BiblesPlugin','Leviticus'), + u'Num': translate('BiblesPlugin','Numbers'), + u'Deut': translate('BiblesPlugin','Deuteronomy'), + u'Josh': translate('BiblesPlugin','Joshua'), + u'Judg': translate('BiblesPlugin','Judges'), + u'Ruth': translate('BiblesPlugin','Ruth'), + u'1Sam': translate('BiblesPlugin','1 Samuel'), + u'2Sam': translate('BiblesPlugin','2 Samuel'), + u'1Kgs': translate('BiblesPlugin','1 Kings'), + u'2Kgs': translate('BiblesPlugin','2 Kings'), + u'1Chr': translate('BiblesPlugin','1 Chronicles'), + u'2Chr': translate('BiblesPlugin','2 Chronicles'), + u'Esra': translate('BiblesPlugin','Ezra'), + u'Neh': translate('BiblesPlugin','Nehemiah'), + u'Esth': translate('BiblesPlugin','Esther'), + u'Job': translate('BiblesPlugin','Job'), + u'Ps': translate('BiblesPlugin','Psalms'), + u'Prov': translate('BiblesPlugin','Proverbs'), + u'Eccl': translate('BiblesPlugin','Ecclesiastes'), + u'Song': translate('BiblesPlugin','Song of Solomon'), + u'Isa': translate('BiblesPlugin','Isaiah'), + u'Jer': translate('BiblesPlugin','Jeremiah'), + u'Lam': translate('BiblesPlugin','Lamentations'), + u'Ezek': translate('BiblesPlugin','Ezekiel'), + u'Dan': translate('BiblesPlugin','Daniel'), + u'Hos': translate('BiblesPlugin','Hosea'), + u'Joel': translate('BiblesPlugin','Joel'), + u'Amos': translate('BiblesPlugin','Amos'), + u'Obad': translate('BiblesPlugin','Obadiah'), + u'Jonah': translate('BiblesPlugin','Jonah'), + u'Mic': translate('BiblesPlugin','Micah'), + u'Nah': translate('BiblesPlugin','Nahum'), + u'Hab': translate('BiblesPlugin','Habakkuk'), + u'Zeph': translate('BiblesPlugin','Zephaniah'), + u'Hag': translate('BiblesPlugin','Haggai'), + u'Zech': translate('BiblesPlugin','Zechariah'), + u'Mal': translate('BiblesPlugin','Malachi'), + u'Matt': translate('BiblesPlugin','Matthew'), + u'Mark': translate('BiblesPlugin','Mark'), + u'Luke': translate('BiblesPlugin','Luke'), + u'John': translate('BiblesPlugin','John'), + u'Acts': translate('BiblesPlugin','Acts'), + u'Rom': translate('BiblesPlugin','Romans'), + u'1Cor': translate('BiblesPlugin','1 Corinthians'), + u'2Cor': translate('BiblesPlugin','2 Corinthians'), + u'Gal': translate('BiblesPlugin','Galatians'), + u'Eph': translate('BiblesPlugin','Ephesians'), + u'Phil': translate('BiblesPlugin','Philippians'), + u'Col': translate('BiblesPlugin','Colossians'), + u'1Thess': translate('BiblesPlugin','1 Thessalonians'), + u'2Thess': translate('BiblesPlugin','2 Thessalonians'), + u'1Tim': translate('BiblesPlugin','1 Timothy'), + u'2Tim': translate('BiblesPlugin','2 Timothy'), + u'Titus': translate('BiblesPlugin','Titus'), + u'Phlm': translate('BiblesPlugin','Philemon'), + u'Heb': translate('BiblesPlugin','Hebrews'), + u'Jas': translate('BiblesPlugin','James'), + u'1Pet': translate('BiblesPlugin','1 Peter'), + u'2Pet': translate('BiblesPlugin','2 Peter'), + u'1John': translate('BiblesPlugin','1 John'), + u'2John': translate('BiblesPlugin','2 John'), + u'3John': translate('BiblesPlugin','3 John'), + u'Jude': translate('BiblesPlugin','Jude'), + u'Rev': translate('BiblesPlugin','Revelation'), + u'Jdt': translate('BiblesPlugin','Judith'), + u'Wis': translate('BiblesPlugin','Wisdom'), + u'Tob': translate('BiblesPlugin','Tobit'), + u'Sir': translate('BiblesPlugin','Sirach'), + u'Bar': translate('BiblesPlugin','Baruch'), + u'1Macc': translate('BiblesPlugin','1 Maccabees'), + u'2Macc': translate('BiblesPlugin','2 Maccabees'), + u'3Macc': translate('BiblesPlugin','3 Maccabees'), + u'4Macc': translate('BiblesPlugin','4 Maccabees'), + u'AddDan': translate('BiblesPlugin','Rest of Daniel'), + u'AddEsth': translate('BiblesPlugin','Rest of Esther'), + u'PrMan': translate('BiblesPlugin','Prayer of Manasses'), + u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'), + u'PrAza': translate('BiblesPlugin','Prayer of Azariah'), + u'Sus': translate('BiblesPlugin','Susanna'), + u'Bel': translate('BiblesPlugin','Bel'), + u'1Esdr': translate('BiblesPlugin','1 Esdras'), + u'2Esdr': translate('BiblesPlugin','2 Esdras') + } def update_reference_separators(): """ @@ -146,7 +235,7 @@ def get_reference_match(match_type): update_reference_separators() return REFERENCE_MATCHES[match_type] -def parse_reference(reference): +def parse_reference(reference, bible, language_selection, book_ref_id=False): """ This is the next generation über-awesome function that takes a person's typed in string and converts it to a list of references to be queried from @@ -154,6 +243,16 @@ def parse_reference(reference): ``reference`` A string. The Bible reference to parse. + + ``bible`` + A object. The Bible database object. + + ``language_selection`` + An int. The language selection the user has choosen in settings + section. + + ``book_ref_id`` + A string. The book reference id. Returns ``None`` or a reference list. @@ -239,6 +338,46 @@ def parse_reference(reference): if match: log.debug(u'Matched reference %s' % reference) book = match.group(u'book') + if not book_ref_id: + booknames = LanguageSelection.Booknames + regex_book = re.compile(u'^[1-4]?[\. ]{0,2}%s' % book.lower(), + re.UNICODE) + if language_selection == LanguageSelection.Bible: + db_book = bible.get_book(book) + if db_book: + book_ref_id = db_book.book_reference_id + elif language_selection == LanguageSelection.Application: + book_list = [] + for k, v in booknames.iteritems(): + if regex_book.search(unicode(v).lower()): + book_list.append(k) + books = [] + if book_list: + for v in book_list: + value = BiblesResourcesDB.get_book(v) + if value: + books.append(value) + if books: + for v in books: + if bible.get_book_by_book_ref_id(v[u'id']): + book_ref_id = v[u'id'] + break + elif language_selection == LanguageSelection.English: + books = BiblesResourcesDB.get_books_like(book) + if books: + book_list = [] + for v in books: + if regex_book.search(v[u'name'].lower()): + book_list.append(v) + if not book_list: + book_list = books + for v in book_list: + if bible.get_book_by_book_ref_id(v[u'id']): + book_ref_id = v[u'id'] + break + else: + if not bible.get_book_by_book_ref_id(book_ref_id): + book_ref_id = False ranges = match.group(u'ranges') range_list = get_reference_match(u'range_separator').split(ranges) ref_list = [] @@ -284,16 +423,18 @@ def parse_reference(reference): if not to_verse: to_verse = -1 if to_chapter > from_chapter: - ref_list.append((book, from_chapter, from_verse, -1)) + ref_list.append((book_ref_id, from_chapter, from_verse, -1)) for i in range(from_chapter + 1, to_chapter): - ref_list.append((book, i, 1, -1)) - ref_list.append((book, to_chapter, 1, to_verse)) + ref_list.append((book_ref_id, i, 1, -1)) + ref_list.append((book_ref_id, to_chapter, 1, to_verse)) elif to_verse >= from_verse or to_verse == -1: - ref_list.append((book, from_chapter, from_verse, to_verse)) + ref_list.append((book_ref_id, from_chapter, + from_verse, to_verse)) elif from_verse: - ref_list.append((book, from_chapter, from_verse, from_verse)) + ref_list.append((book_ref_id, from_chapter, + from_verse, from_verse)) else: - ref_list.append((book, from_chapter, 1, -1)) + ref_list.append((book_ref_id, from_chapter, 1, -1)) return ref_list else: log.debug(u'Invalid reference: %s' % reference) diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index 5f3b7a6c9..b419bebc0 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -435,19 +435,19 @@ class BibleDB(QtCore.QObject, Manager): else: return count - def get_verse_count(self, book_id, chapter): + def get_verse_count(self, book_ref_id, chapter): """ Return the number of verses in a chapter. - ``book`` - The book containing the chapter. + ``book_ref_id`` + The book reference id. ``chapter`` The chapter to get the verse count for. """ - log.debug(u'BibleDB.get_verse_count("%s", "%s")', book_id, chapter) + log.debug(u'BibleDB.get_verse_count("%s", "%s")', book_ref_id, chapter) count = self.session.query(Verse).join(Book)\ - .filter(Book.book_reference_id==book_id)\ + .filter(Book.book_reference_id==book_ref_id)\ .filter(Verse.chapter==chapter)\ .count() if not count: @@ -595,6 +595,35 @@ class BiblesResourcesDB(QtCore.QObject, Manager): else: return None + @staticmethod + def get_books_like(string): + """ + Return the books which include string. + + ``string`` + The string to search for in the booknames or abbreviations. + """ + log.debug(u'BiblesResourcesDB.get_book_like("%s")', string) + if not isinstance(string, unicode): + name = unicode(string) + books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' + u'abbreviation, chapters FROM book_reference WHERE ' + u'LOWER(name) LIKE ? OR LOWER(abbreviation) LIKE ?', + (u'%'+string.lower()+u'%', u'%'+string.lower()+u'%')) + if books: + return [ + { + u'id': book[0], + u'testament_id': book[1], + u'name': unicode(book[2]), + u'abbreviation': unicode(book[3]), + u'chapters': book[4] + } + for book in books + ] + else: + return None + @staticmethod def get_book_by_id(id): """ @@ -621,23 +650,23 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_chapter(book_id, chapter): + def get_chapter(book_ref_id, chapter): """ Return the chapter details for a specific chapter of a book. - ``book_id`` + ``book_ref_id`` The id of a book. ``chapter`` The chapter number. """ - log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_id, + log.debug(u'BiblesResourcesDB.get_chapter("%s", "%s")', book_ref_id, chapter) if not isinstance(chapter, int): chapter = int(chapter) chapters = BiblesResourcesDB.run_sql(u'SELECT id, book_reference_id, ' u'chapter, verse_count FROM chapters WHERE book_reference_id = ?', - (book_id,)) + (book_ref_id,)) try: return { u'id': chapters[chapter-1][0], @@ -649,21 +678,21 @@ class BiblesResourcesDB(QtCore.QObject, Manager): return None @staticmethod - def get_chapter_count(book_id): + def get_chapter_count(book_ref_id): """ Return the number of chapters in a book. - ``book_id`` + ``book_ref_id`` The id of the book. """ - log.debug(u'BiblesResourcesDB.get_chapter_count("%s")', book_id) - details = BiblesResourcesDB.get_book_by_id(book_id) + log.debug(u'BiblesResourcesDB.get_chapter_count("%s")', book_ref_id) + details = BiblesResourcesDB.get_book_by_id(book_ref_id) if details: return details[u'chapters'] return 0 @staticmethod - def get_verse_count(book_id, chapter): + def get_verse_count(book_ref_id, chapter): """ Return the number of verses in a chapter. @@ -673,9 +702,9 @@ class BiblesResourcesDB(QtCore.QObject, Manager): ``chapter`` The number of the chapter. """ - log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_id, + log.debug(u'BiblesResourcesDB.get_verse_count("%s", "%s")', book_ref_id, chapter) - details = BiblesResourcesDB.get_chapter(book_id, chapter) + details = BiblesResourcesDB.get_chapter(book_ref_id, chapter) if details: return details[u'verse_count'] return 0 diff --git a/openlp/plugins/bibles/lib/manager.py b/openlp/plugins/bibles/lib/manager.py index 411e25367..c9f564b2c 100644 --- a/openlp/plugins/bibles/lib/manager.py +++ b/openlp/plugins/bibles/lib/manager.py @@ -33,7 +33,8 @@ from PyQt4 import QtCore from openlp.core.lib import Receiver, SettingsManager, translate from openlp.core.lib.ui import critical_error_message_box from openlp.core.utils import AppLocation, delete_file -from openlp.plugins.bibles.lib import parse_reference, get_reference_separator +from openlp.plugins.bibles.lib import parse_reference, \ + get_reference_separator, LanguageSelection from openlp.plugins.bibles.lib.db import BibleDB, BibleMeta from csvbible import CSVBible from http import HTTPBible @@ -265,7 +266,16 @@ class BibleManager(object): book_ref_id = db_book.book_reference_id return self.db_cache[bible].get_verse_count(book_ref_id, chapter) - def get_verses(self, bible, versetext, firstbible=False, show_error=True): + def get_verse_count_by_book_ref_id(self, bible, book_ref_id, chapter): + """ + Returns all the number of verses for a given + book_ref_id and chapterMaxBibleBookVerses. + """ + log.debug(u'BibleManager.get_verse_count_by_book_ref_id("%s", "%s", ' + u'"%s")', bible, book_ref_id, chapter) + return self.db_cache[bible].get_verse_count(book_ref_id, chapter) + + def get_verses(self, bible, versetext, book_ref_id=False, show_error=True): """ Parses a scripture reference, fetches the verses from the Bible specified, and returns a list of ``Verse`` objects. @@ -283,6 +293,10 @@ class BibleManager(object): - Genesis 1:1-10,15-20 - Genesis 1:1-2:10 - Genesis 1:1-10,2:1-10 + + ``book_ref_id`` + Unicode. The book referece id from the book in versetext. + For second bible this is necessary. """ log.debug(u'BibleManager.get_verses("%s", "%s")', bible, versetext) if not bible: @@ -295,30 +309,12 @@ class BibleManager(object): 'Import Wizard to install one or more Bibles.') }) return None - reflist = parse_reference(versetext) + language_selection = QtCore.QSettings().value( + self.settingsSection + u'/bookname language', + QtCore.QVariant(0)).toInt()[0] + reflist = parse_reference(versetext, self.db_cache[bible], + language_selection, book_ref_id) if reflist: - new_reflist = [] - for item in reflist: - if item: - if firstbible: - db_book = self.db_cache[firstbible].get_book(item[0]) - db_book = self.db_cache[bible].get_book_by_book_ref_id( - db_book.book_reference_id) - else: - db_book = self.db_cache[bible].get_book(item[0]) - if db_book: - book_id = db_book.book_reference_id - log.debug(u'Book name corrected to "%s"', db_book.name) - new_reflist.append((book_id, item[1], item[2], - item[3])) - else: - log.debug(u'OpenLP failed to find book %s', item[0]) - critical_error_message_box( - translate('BiblesPlugin', 'No Book Found'), - translate('BiblesPlugin', 'No matching book ' - 'could be found in this Bible. Check that you have ' - 'spelled the name of the book correctly.')) - reflist = new_reflist return self.db_cache[bible].get_verses(reflist, show_error) else: if show_error: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 50872aef3..2025b4187 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -428,7 +428,8 @@ class BibleMediaItem(MediaManagerItem): first = True language_selection = QtCore.QSettings().value( self.settingsSection + u'/bookname language', - QtCore.QVariant(0)).toInt()[0] + QtCore.QVariant(0)).toInt()[0] + booknames = LanguageSelection.Booknames for book in book_data: row = self.advancedBookComboBox.count() if language_selection == LanguageSelection.Bible: @@ -436,10 +437,8 @@ class BibleMediaItem(MediaManagerItem): elif language_selection == LanguageSelection.Application: data = BiblesResourcesDB.get_book_by_id( book[u'book_reference_id']) - abbr = data[u'abbreviation'].replace(u'1', u'First').\ - replace(u'2', u'Second').replace(u'3', u'Third').\ - replace(u'4', u'Fourth') - self.advancedBookComboBox.addItem(getattr(BibleStrings, abbr)) + self.advancedBookComboBox.addItem( + booknames[data[u'abbreviation']]) elif language_selection == LanguageSelection.English: data = BiblesResourcesDB.get_book_by_id( book[u'book_reference_id']) @@ -456,7 +455,8 @@ class BibleMediaItem(MediaManagerItem): book_ref_id) book = self.plugin.manager.get_book_by_id(bible, book_ref_id) self.chapter_count = self.plugin.manager.get_chapter_count(bible, book) - verse_count = self.plugin.manager.get_verse_count(bible, book.name, 1) + verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, + book_ref_id, 1) if verse_count == 0: self.advancedSearchButton.setEnabled(False) critical_error_message_box( @@ -475,6 +475,7 @@ class BibleMediaItem(MediaManagerItem): completion depends on the bible. It is only updated when we are doing a reference search, otherwise the auto completion list is removed. """ + log.debug(u'updateAutoCompleter') # Save the current search type to the configuration. QtCore.QSettings().setValue(u'%s/last search type' % self.settingsSection, @@ -501,17 +502,15 @@ class BibleMediaItem(MediaManagerItem): book_data = book_data_temp language_selection = QtCore.QSettings().value( self.settingsSection + u'/bookname language', - QtCore.QVariant(0)).toInt()[0] + QtCore.QVariant(0)).toInt()[0] if language_selection == LanguageSelection.Bible: books = [book.name + u' ' for book in book_data] elif language_selection == LanguageSelection.Application: + booknames = LanguageSelection.Booknames for book in book_data: data = BiblesResourcesDB.get_book_by_id( book.book_reference_id) - abbr = data[u'abbreviation'].replace(u'1', u'First').\ - replace(u'2', u'Second').replace(u'3', u'Third').\ - replace(u'4', u'Fourth') - books.append(getattr(BibleStrings, abbr) + u' ') + books.append(data[u'name'] + u' ') elif language_selection == LanguageSelection.English: for book in book_data: data = BiblesResourcesDB.get_book_by_id( @@ -590,22 +589,24 @@ class BibleMediaItem(MediaManagerItem): chapter_to = int(self.advancedToChapter.currentText()) if chapter_from == chapter_to: bible = unicode(self.advancedVersionComboBox.currentText()) - book = unicode(self.advancedBookComboBox.currentText()) + book_ref_id = unicode(self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString()) verse_from = int(self.advancedFromVerse.currentText()) - verse_count = self.plugin.manager.get_verse_count(bible, book, - chapter_to) + verse_count = self.plugin.manager.get_verse_count_by_book_ref_id( + bible, book_ref_id, chapter_to) self.adjustComboBox(verse_from, verse_count, self.advancedToVerse, True) def onAdvancedToChapter(self): bible = unicode(self.advancedVersionComboBox.currentText()) - book = unicode(self.advancedBookComboBox.currentText()) + book_ref_id = unicode(self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString()) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) verse_from = int(self.advancedFromVerse.currentText()) verse_to = int(self.advancedToVerse.currentText()) - verse_count = self.plugin.manager.get_verse_count(bible, book, - chapter_to) + verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, + book_ref_id, chapter_to) if chapter_from == chapter_to and verse_from > verse_to: self.adjustComboBox(verse_from, verse_count, self.advancedToVerse) else: @@ -613,11 +614,12 @@ class BibleMediaItem(MediaManagerItem): def onAdvancedFromChapter(self): bible = unicode(self.advancedVersionComboBox.currentText()) - book = unicode(self.advancedBookComboBox.currentText()) + book_ref_id = unicode(self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString()) chapter_from = int(self.advancedFromChapter.currentText()) chapter_to = int(self.advancedToChapter.currentText()) - verse_count = self.plugin.manager.get_verse_count(bible, book, - chapter_from) + verse_count = self.plugin.manager.get_verse_count_by_book_ref_id(bible, + book_ref_id, chapter_from) self.adjustComboBox(1, verse_count, self.advancedFromVerse) if chapter_from > chapter_to: self.adjustComboBox(1, verse_count, self.advancedToVerse) @@ -666,6 +668,8 @@ class BibleMediaItem(MediaManagerItem): bible = unicode(self.advancedVersionComboBox.currentText()) second_bible = unicode(self.advancedSecondComboBox.currentText()) book = unicode(self.advancedBookComboBox.currentText()) + book_ref_id = unicode(self.advancedBookComboBox.itemData( + int(self.advancedBookComboBox.currentIndex())).toString()) chapter_from = self.advancedFromChapter.currentText() chapter_to = self.advancedToChapter.currentText() verse_from = self.advancedFromVerse.currentText() @@ -676,10 +680,11 @@ class BibleMediaItem(MediaManagerItem): range_separator + chapter_to + verse_separator + verse_to versetext = u'%s %s' % (book, verse_range) Receiver.send_message(u'cursor_busy') - self.search_results = self.plugin.manager.get_verses(bible, versetext) + self.search_results = self.plugin.manager.get_verses(bible, versetext, + book_ref_id) if second_bible: self.second_search_results = self.plugin.manager.get_verses( - second_bible, versetext, bible) + second_bible, versetext, book_ref_id) if not self.advancedLockButton.isChecked(): self.listView.clear() if self.listView.count() != 0: @@ -707,7 +712,8 @@ class BibleMediaItem(MediaManagerItem): self.search_results = self.plugin.manager.get_verses(bible, text) if second_bible and self.search_results: self.second_search_results = self.plugin.manager.get_verses( - second_bible, text, bible) + second_bible, text, + self.search_results[0].book.book_reference_id) else: # We are doing a 'Text Search'. Receiver.send_message(u'cursor_busy') @@ -1025,8 +1031,7 @@ class BibleMediaItem(MediaManagerItem): Search for some Bible verses (by reference). """ bible = unicode(self.quickVersionComboBox.currentText()) - search_results = self.plugin.manager.get_verses(bible, string, False, - False) + search_results = self.plugin.manager.get_verses(bible, string, False) if search_results: versetext = u' '.join([verse.text for verse in search_results]) return [[string, versetext]] From c850d4fecd73a2b2e82961fb444d8a90808bdb10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 4 Mar 2012 21:39:52 +0100 Subject: [PATCH 3/6] remove unnecessary code --- openlp/plugins/bibles/lib/mediaitem.py | 1 - openlp/plugins/bibles/lib/ui.py | 121 ------------------------- 2 files changed, 122 deletions(-) delete mode 100644 openlp/plugins/bibles/lib/ui.py diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index 2025b4187..c327d1da0 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -39,7 +39,6 @@ from openlp.core.lib.ui import UiStrings, add_widget_completer, \ from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ VerseReferenceList, get_reference_separator, LanguageSelection -from openlp.plugins.bibles.lib.ui import BibleStrings from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) diff --git a/openlp/plugins/bibles/lib/ui.py b/openlp/plugins/bibles/lib/ui.py deleted file mode 100644 index ca9c35785..000000000 --- a/openlp/plugins/bibles/lib/ui.py +++ /dev/null @@ -1,121 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) Second008-2012 Raoul Snyman # -# Portions copyright (c) Second008-2012 Tim Bentley, Gerald Britton, Jonathan # -# Corwin, Michael Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, # -# Armin Köhler, Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias # -# Põldaru, Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, # -# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode Woldsund # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version Second of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### -""" -The :mod:`openlp.plugins.bibles.lib.ui` module provides standard UI components -for the bibles plugin. -""" -from openlp.core.lib import translate - -class BibleStrings(object): - """ - Provide standard strings for use throughout the bibles plugin. - """ - # These strings should need a good reason to be retranslated elsewhere. - Gen = translate('OpenLP.Ui','Genesis') - Exod = translate('OpenLP.Ui','Exodus') - Lev = translate('OpenLP.Ui','Leviticus') - Num = translate('OpenLP.Ui','Numbers') - Deut = translate('OpenLP.Ui','Deuteronomy') - Josh = translate('OpenLP.Ui','Joshua') - Judg = translate('OpenLP.Ui','Judges') - Ruth = translate('OpenLP.Ui','Ruth') - FirstSam = translate('OpenLP.Ui','1 Samuel') - SecondSam = translate('OpenLP.Ui','2 Samuel') - FirstKgs = translate('OpenLP.Ui','1 Kings') - SecondKgs = translate('OpenLP.Ui','2 Kings') - FirstChr = translate('OpenLP.Ui','1 Chronicles') - SecondChr = translate('OpenLP.Ui','2 Chronicles') - Esra = translate('OpenLP.Ui','Ezra') - Neh = translate('OpenLP.Ui','Nehemiah') - Esth = translate('OpenLP.Ui','Esther') - Job = translate('OpenLP.Ui','Job') - Ps = translate('OpenLP.Ui','Psalms') - Prov = translate('OpenLP.Ui','Proverbs') - Eccl = translate('OpenLP.Ui','Ecclesiastes') - Song = translate('OpenLP.Ui','Song of Solomon') - Isa = translate('OpenLP.Ui','Isaiah') - Jer = translate('OpenLP.Ui','Jeremiah') - Lam = translate('OpenLP.Ui','Lamentations') - Ezek = translate('OpenLP.Ui','Ezekiel') - Dan = translate('OpenLP.Ui','Daniel') - Hos = translate('OpenLP.Ui','Hosea') - Joel = translate('OpenLP.Ui','Joel') - Amos= translate('OpenLP.Ui','Amos') - Obad = translate('OpenLP.Ui','Obadiah') - Jonah = translate('OpenLP.Ui','Jonah') - Mic = translate('OpenLP.Ui','Micah') - Nah = translate('OpenLP.Ui','Nahum') - Hab = translate('OpenLP.Ui','Habakkuk') - Zeph = translate('OpenLP.Ui','Zephaniah') - Hag = translate('OpenLP.Ui','Haggai') - Zech = translate('OpenLP.Ui','Zechariah') - Mal = translate('OpenLP.Ui','Malachi') - Matt = translate('OpenLP.Ui','Matthew') - Mark = translate('OpenLP.Ui','Mark') - Luke = translate('OpenLP.Ui','Luke') - John = translate('OpenLP.Ui','John') - Acts = translate('OpenLP.Ui','Acts') - Rom = translate('OpenLP.Ui','Romans') - FirstCor = translate('OpenLP.Ui','1 Corinthians') - SecondCor = translate('OpenLP.Ui','2 Corinthians') - Gal = translate('OpenLP.Ui','Galatians') - Eph = translate('OpenLP.Ui','Ephesians') - Phil = translate('OpenLP.Ui','Philippians') - Col = translate('OpenLP.Ui','Colossians') - FirstThess = translate('OpenLP.Ui','1 Thessalonians') - SecondThess = translate('OpenLP.Ui','2 Thessalonians') - FirstTim = translate('OpenLP.Ui','1 Timothy') - SecondTim = translate('OpenLP.Ui','2 Timothy') - Titus = translate('OpenLP.Ui','Titus') - Phlm = translate('OpenLP.Ui','Philemon') - Heb = translate('OpenLP.Ui','Hebrews') - Jas = translate('OpenLP.Ui','James') - FirstPet = translate('OpenLP.Ui','1 Peter') - SecondPet = translate('OpenLP.Ui','2 Peter') - FirstJohn = translate('OpenLP.Ui','1 John') - SecondJohn = translate('OpenLP.Ui','2 John') - ThirdJohn = translate('OpenLP.Ui','3 John') - Jude = translate('OpenLP.Ui','Jude') - Rev = translate('OpenLP.Ui','Revelation') - Jdt = translate('OpenLP.Ui','Judith') - Wis = translate('OpenLP.Ui','Wisdom') - Tob = translate('OpenLP.Ui','Tobit') - Sir = translate('OpenLP.Ui','Sirach') - Bar = translate('OpenLP.Ui','Baruch') - FirstMacc = translate('OpenLP.Ui','1 Maccabees') - SecondMacc = translate('OpenLP.Ui','2 Maccabees') - ThirdMacc = translate('OpenLP.Ui','3 Maccabees') - FourthMacc = translate('OpenLP.Ui','4 Maccabees') - AddDan = translate('OpenLP.Ui','Rest of Daniel') - AddEsth = translate('OpenLP.Ui','Rest of Esther') - PrMan = translate('OpenLP.Ui','Prayer of Manasses') - LetJer = translate('OpenLP.Ui','Letter of Jeremiah') - PrAza = translate('OpenLP.Ui','Prayer of Azariah') - Sus = translate('OpenLP.Ui','Susanna') - Bel = translate('OpenLP.Ui','Bel') - FirstEsdr = translate('OpenLP.Ui','1 Esdras') - SecondEsdr = translate('OpenLP.Ui','2 Esdras') From 5391301b9768051c7fd559b7ab6d5ab12c9d20dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sun, 4 Mar 2012 22:50:32 +0100 Subject: [PATCH 4/6] change BibleStrings object --- openlp/plugins/bibles/lib/__init__.py | 197 ++++++++++++++----------- openlp/plugins/bibles/lib/mediaitem.py | 6 +- 2 files changed, 112 insertions(+), 91 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 51d7f483a..acbff1964 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -59,6 +59,7 @@ class DisplayStyle(object): Curly = 2 Square = 3 + class LanguageSelection(object): """ An enumeration for bible bookname language. @@ -67,93 +68,113 @@ class LanguageSelection(object): Bible = 0 Application = 1 English = 2 - - Booknames = { - u'Gen': translate('BiblesPlugin','Genesis'), - u'Exod': translate('BiblesPlugin','Exodus'), - u'Lev': translate('BiblesPlugin','Leviticus'), - u'Num': translate('BiblesPlugin','Numbers'), - u'Deut': translate('BiblesPlugin','Deuteronomy'), - u'Josh': translate('BiblesPlugin','Joshua'), - u'Judg': translate('BiblesPlugin','Judges'), - u'Ruth': translate('BiblesPlugin','Ruth'), - u'1Sam': translate('BiblesPlugin','1 Samuel'), - u'2Sam': translate('BiblesPlugin','2 Samuel'), - u'1Kgs': translate('BiblesPlugin','1 Kings'), - u'2Kgs': translate('BiblesPlugin','2 Kings'), - u'1Chr': translate('BiblesPlugin','1 Chronicles'), - u'2Chr': translate('BiblesPlugin','2 Chronicles'), - u'Esra': translate('BiblesPlugin','Ezra'), - u'Neh': translate('BiblesPlugin','Nehemiah'), - u'Esth': translate('BiblesPlugin','Esther'), - u'Job': translate('BiblesPlugin','Job'), - u'Ps': translate('BiblesPlugin','Psalms'), - u'Prov': translate('BiblesPlugin','Proverbs'), - u'Eccl': translate('BiblesPlugin','Ecclesiastes'), - u'Song': translate('BiblesPlugin','Song of Solomon'), - u'Isa': translate('BiblesPlugin','Isaiah'), - u'Jer': translate('BiblesPlugin','Jeremiah'), - u'Lam': translate('BiblesPlugin','Lamentations'), - u'Ezek': translate('BiblesPlugin','Ezekiel'), - u'Dan': translate('BiblesPlugin','Daniel'), - u'Hos': translate('BiblesPlugin','Hosea'), - u'Joel': translate('BiblesPlugin','Joel'), - u'Amos': translate('BiblesPlugin','Amos'), - u'Obad': translate('BiblesPlugin','Obadiah'), - u'Jonah': translate('BiblesPlugin','Jonah'), - u'Mic': translate('BiblesPlugin','Micah'), - u'Nah': translate('BiblesPlugin','Nahum'), - u'Hab': translate('BiblesPlugin','Habakkuk'), - u'Zeph': translate('BiblesPlugin','Zephaniah'), - u'Hag': translate('BiblesPlugin','Haggai'), - u'Zech': translate('BiblesPlugin','Zechariah'), - u'Mal': translate('BiblesPlugin','Malachi'), - u'Matt': translate('BiblesPlugin','Matthew'), - u'Mark': translate('BiblesPlugin','Mark'), - u'Luke': translate('BiblesPlugin','Luke'), - u'John': translate('BiblesPlugin','John'), - u'Acts': translate('BiblesPlugin','Acts'), - u'Rom': translate('BiblesPlugin','Romans'), - u'1Cor': translate('BiblesPlugin','1 Corinthians'), - u'2Cor': translate('BiblesPlugin','2 Corinthians'), - u'Gal': translate('BiblesPlugin','Galatians'), - u'Eph': translate('BiblesPlugin','Ephesians'), - u'Phil': translate('BiblesPlugin','Philippians'), - u'Col': translate('BiblesPlugin','Colossians'), - u'1Thess': translate('BiblesPlugin','1 Thessalonians'), - u'2Thess': translate('BiblesPlugin','2 Thessalonians'), - u'1Tim': translate('BiblesPlugin','1 Timothy'), - u'2Tim': translate('BiblesPlugin','2 Timothy'), - u'Titus': translate('BiblesPlugin','Titus'), - u'Phlm': translate('BiblesPlugin','Philemon'), - u'Heb': translate('BiblesPlugin','Hebrews'), - u'Jas': translate('BiblesPlugin','James'), - u'1Pet': translate('BiblesPlugin','1 Peter'), - u'2Pet': translate('BiblesPlugin','2 Peter'), - u'1John': translate('BiblesPlugin','1 John'), - u'2John': translate('BiblesPlugin','2 John'), - u'3John': translate('BiblesPlugin','3 John'), - u'Jude': translate('BiblesPlugin','Jude'), - u'Rev': translate('BiblesPlugin','Revelation'), - u'Jdt': translate('BiblesPlugin','Judith'), - u'Wis': translate('BiblesPlugin','Wisdom'), - u'Tob': translate('BiblesPlugin','Tobit'), - u'Sir': translate('BiblesPlugin','Sirach'), - u'Bar': translate('BiblesPlugin','Baruch'), - u'1Macc': translate('BiblesPlugin','1 Maccabees'), - u'2Macc': translate('BiblesPlugin','2 Maccabees'), - u'3Macc': translate('BiblesPlugin','3 Maccabees'), - u'4Macc': translate('BiblesPlugin','4 Maccabees'), - u'AddDan': translate('BiblesPlugin','Rest of Daniel'), - u'AddEsth': translate('BiblesPlugin','Rest of Esther'), - u'PrMan': translate('BiblesPlugin','Prayer of Manasses'), - u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'), - u'PrAza': translate('BiblesPlugin','Prayer of Azariah'), - u'Sus': translate('BiblesPlugin','Susanna'), - u'Bel': translate('BiblesPlugin','Bel'), - u'1Esdr': translate('BiblesPlugin','1 Esdras'), - u'2Esdr': translate('BiblesPlugin','2 Esdras') - } + + +class BibleStrings(object): + """ + Provide standard strings for objects to use. + """ + __instance__ = None + + def __new__(cls): + """ + Override the default object creation method to return a single instance. + """ + if not cls.__instance__: + cls.__instance__ = object.__new__(cls) + return cls.__instance__ + + def __init__(self): + """ + These strings should need a good reason to be retranslated elsewhere. + """ + self.Booknames = { + u'Gen': translate('BiblesPlugin','Genesis'), + u'Exod': translate('BiblesPlugin','Exodus'), + u'Lev': translate('BiblesPlugin','Leviticus'), + u'Num': translate('BiblesPlugin','Numbers'), + u'Deut': translate('BiblesPlugin','Deuteronomy'), + u'Josh': translate('BiblesPlugin','Joshua'), + u'Judg': translate('BiblesPlugin','Judges'), + u'Ruth': translate('BiblesPlugin','Ruth'), + u'1Sam': translate('BiblesPlugin','1 Samuel'), + u'2Sam': translate('BiblesPlugin','2 Samuel'), + u'1Kgs': translate('BiblesPlugin','1 Kings'), + u'2Kgs': translate('BiblesPlugin','2 Kings'), + u'1Chr': translate('BiblesPlugin','1 Chronicles'), + u'2Chr': translate('BiblesPlugin','2 Chronicles'), + u'Esra': translate('BiblesPlugin','Ezra'), + u'Neh': translate('BiblesPlugin','Nehemiah'), + u'Esth': translate('BiblesPlugin','Esther'), + u'Job': translate('BiblesPlugin','Job'), + u'Ps': translate('BiblesPlugin','Psalms'), + u'Prov': translate('BiblesPlugin','Proverbs'), + u'Eccl': translate('BiblesPlugin','Ecclesiastes'), + u'Song': translate('BiblesPlugin','Song of Solomon'), + u'Isa': translate('BiblesPlugin','Isaiah'), + u'Jer': translate('BiblesPlugin','Jeremiah'), + u'Lam': translate('BiblesPlugin','Lamentations'), + u'Ezek': translate('BiblesPlugin','Ezekiel'), + u'Dan': translate('BiblesPlugin','Daniel'), + u'Hos': translate('BiblesPlugin','Hosea'), + u'Joel': translate('BiblesPlugin','Joel'), + u'Amos': translate('BiblesPlugin','Amos'), + u'Obad': translate('BiblesPlugin','Obadiah'), + u'Jonah': translate('BiblesPlugin','Jonah'), + u'Mic': translate('BiblesPlugin','Micah'), + u'Nah': translate('BiblesPlugin','Nahum'), + u'Hab': translate('BiblesPlugin','Habakkuk'), + u'Zeph': translate('BiblesPlugin','Zephaniah'), + u'Hag': translate('BiblesPlugin','Haggai'), + u'Zech': translate('BiblesPlugin','Zechariah'), + u'Mal': translate('BiblesPlugin','Malachi'), + u'Matt': translate('BiblesPlugin','Matthew'), + u'Mark': translate('BiblesPlugin','Mark'), + u'Luke': translate('BiblesPlugin','Luke'), + u'John': translate('BiblesPlugin','John'), + u'Acts': translate('BiblesPlugin','Acts'), + u'Rom': translate('BiblesPlugin','Romans'), + u'1Cor': translate('BiblesPlugin','1 Corinthians'), + u'2Cor': translate('BiblesPlugin','2 Corinthians'), + u'Gal': translate('BiblesPlugin','Galatians'), + u'Eph': translate('BiblesPlugin','Ephesians'), + u'Phil': translate('BiblesPlugin','Philippians'), + u'Col': translate('BiblesPlugin','Colossians'), + u'1Thess': translate('BiblesPlugin','1 Thessalonians'), + u'2Thess': translate('BiblesPlugin','2 Thessalonians'), + u'1Tim': translate('BiblesPlugin','1 Timothy'), + u'2Tim': translate('BiblesPlugin','2 Timothy'), + u'Titus': translate('BiblesPlugin','Titus'), + u'Phlm': translate('BiblesPlugin','Philemon'), + u'Heb': translate('BiblesPlugin','Hebrews'), + u'Jas': translate('BiblesPlugin','James'), + u'1Pet': translate('BiblesPlugin','1 Peter'), + u'2Pet': translate('BiblesPlugin','2 Peter'), + u'1John': translate('BiblesPlugin','1 John'), + u'2John': translate('BiblesPlugin','2 John'), + u'3John': translate('BiblesPlugin','3 John'), + u'Jude': translate('BiblesPlugin','Jude'), + u'Rev': translate('BiblesPlugin','Revelation'), + u'Jdt': translate('BiblesPlugin','Judith'), + u'Wis': translate('BiblesPlugin','Wisdom'), + u'Tob': translate('BiblesPlugin','Tobit'), + u'Sir': translate('BiblesPlugin','Sirach'), + u'Bar': translate('BiblesPlugin','Baruch'), + u'1Macc': translate('BiblesPlugin','1 Maccabees'), + u'2Macc': translate('BiblesPlugin','2 Maccabees'), + u'3Macc': translate('BiblesPlugin','3 Maccabees'), + u'4Macc': translate('BiblesPlugin','4 Maccabees'), + u'AddDan': translate('BiblesPlugin','Rest of Daniel'), + u'AddEsth': translate('BiblesPlugin','Rest of Esther'), + u'PrMan': translate('BiblesPlugin','Prayer of Manasses'), + u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'), + u'PrAza': translate('BiblesPlugin','Prayer of Azariah'), + u'Sus': translate('BiblesPlugin','Susanna'), + u'Bel': translate('BiblesPlugin','Bel'), + u'1Esdr': translate('BiblesPlugin','1 Esdras'), + u'2Esdr': translate('BiblesPlugin','2 Esdras') + } + def update_reference_separators(): """ @@ -339,7 +360,7 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False): log.debug(u'Matched reference %s' % reference) book = match.group(u'book') if not book_ref_id: - booknames = LanguageSelection.Booknames + booknames = BibleStrings().Booknames regex_book = re.compile(u'^[1-4]?[\. ]{0,2}%s' % book.lower(), re.UNICODE) if language_selection == LanguageSelection.Bible: diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index c327d1da0..976ff6106 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -38,7 +38,7 @@ from openlp.core.lib.ui import UiStrings, add_widget_completer, \ find_and_set_in_combo_box, build_icon from openlp.plugins.bibles.forms import BibleImportForm from openlp.plugins.bibles.lib import LayoutStyle, DisplayStyle, \ - VerseReferenceList, get_reference_separator, LanguageSelection + VerseReferenceList, get_reference_separator, LanguageSelection, BibleStrings from openlp.plugins.bibles.lib.db import BiblesResourcesDB log = logging.getLogger(__name__) @@ -428,7 +428,7 @@ class BibleMediaItem(MediaManagerItem): language_selection = QtCore.QSettings().value( self.settingsSection + u'/bookname language', QtCore.QVariant(0)).toInt()[0] - booknames = LanguageSelection.Booknames + booknames = BibleStrings().Booknames for book in book_data: row = self.advancedBookComboBox.count() if language_selection == LanguageSelection.Bible: @@ -505,7 +505,7 @@ class BibleMediaItem(MediaManagerItem): if language_selection == LanguageSelection.Bible: books = [book.name + u' ' for book in book_data] elif language_selection == LanguageSelection.Application: - booknames = LanguageSelection.Booknames + booknames = BibleStrings().Booknames for book in book_data: data = BiblesResourcesDB.get_book_by_id( book.book_reference_id) From 905fc6d91fc4b07dd50a3ea4c2159e07632ef5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Wed, 7 Mar 2012 20:15:38 +0100 Subject: [PATCH 5/6] adapt regex and some variable names --- openlp/plugins/bibles/lib/__init__.py | 41 +++++++++++++++------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index acbff1964..987f7e79e 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -361,40 +361,45 @@ def parse_reference(reference, bible, language_selection, book_ref_id=False): book = match.group(u'book') if not book_ref_id: booknames = BibleStrings().Booknames - regex_book = re.compile(u'^[1-4]?[\. ]{0,2}%s' % book.lower(), - re.UNICODE) + # escape reserved characters + book_escaped = book + for character in u'\\.^$*+?{}[]()': + book_escaped = book_escaped.replace( + character, u'\\' + character) + regex_book = re.compile(u'\s*%s\s*' % u'\s*'.join( + book_escaped.split()), re.UNICODE | re.IGNORECASE) if language_selection == LanguageSelection.Bible: db_book = bible.get_book(book) if db_book: book_ref_id = db_book.book_reference_id elif language_selection == LanguageSelection.Application: book_list = [] - for k, v in booknames.iteritems(): - if regex_book.search(unicode(v).lower()): - book_list.append(k) + for key, value in booknames.iteritems(): + if regex_book.match(unicode(value)): + book_list.append(key) books = [] if book_list: - for v in book_list: - value = BiblesResourcesDB.get_book(v) - if value: - books.append(value) + for value in book_list: + item = BiblesResourcesDB.get_book(value) + if item: + books.append(item) if books: - for v in books: - if bible.get_book_by_book_ref_id(v[u'id']): - book_ref_id = v[u'id'] + for value in books: + if bible.get_book_by_book_ref_id(value[u'id']): + book_ref_id = value[u'id'] break elif language_selection == LanguageSelection.English: books = BiblesResourcesDB.get_books_like(book) if books: book_list = [] - for v in books: - if regex_book.search(v[u'name'].lower()): - book_list.append(v) + for value in books: + if regex_book.match(value[u'name']): + book_list.append(value) if not book_list: book_list = books - for v in book_list: - if bible.get_book_by_book_ref_id(v[u'id']): - book_ref_id = v[u'id'] + for value in book_list: + if bible.get_book_by_book_ref_id(value[u'id']): + book_ref_id = value[u'id'] break else: if not bible.get_book_by_book_ref_id(book_ref_id): From 06cce54788c99ead15597af36a34949ab4eb52a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armin=20K=C3=B6hler?= Date: Sat, 10 Mar 2012 20:12:03 +0100 Subject: [PATCH 6/6] fix some mission spaces and addapt some strings --- openlp/plugins/bibles/lib/__init__.py | 168 ++++++++++++------------- openlp/plugins/bibles/lib/biblestab.py | 11 +- openlp/plugins/bibles/lib/db.py | 2 +- 3 files changed, 90 insertions(+), 91 deletions(-) diff --git a/openlp/plugins/bibles/lib/__init__.py b/openlp/plugins/bibles/lib/__init__.py index 987f7e79e..65fd3d543 100644 --- a/openlp/plugins/bibles/lib/__init__.py +++ b/openlp/plugins/bibles/lib/__init__.py @@ -89,90 +89,90 @@ class BibleStrings(object): These strings should need a good reason to be retranslated elsewhere. """ self.Booknames = { - u'Gen': translate('BiblesPlugin','Genesis'), - u'Exod': translate('BiblesPlugin','Exodus'), - u'Lev': translate('BiblesPlugin','Leviticus'), - u'Num': translate('BiblesPlugin','Numbers'), - u'Deut': translate('BiblesPlugin','Deuteronomy'), - u'Josh': translate('BiblesPlugin','Joshua'), - u'Judg': translate('BiblesPlugin','Judges'), - u'Ruth': translate('BiblesPlugin','Ruth'), - u'1Sam': translate('BiblesPlugin','1 Samuel'), - u'2Sam': translate('BiblesPlugin','2 Samuel'), - u'1Kgs': translate('BiblesPlugin','1 Kings'), - u'2Kgs': translate('BiblesPlugin','2 Kings'), - u'1Chr': translate('BiblesPlugin','1 Chronicles'), - u'2Chr': translate('BiblesPlugin','2 Chronicles'), - u'Esra': translate('BiblesPlugin','Ezra'), - u'Neh': translate('BiblesPlugin','Nehemiah'), - u'Esth': translate('BiblesPlugin','Esther'), - u'Job': translate('BiblesPlugin','Job'), - u'Ps': translate('BiblesPlugin','Psalms'), - u'Prov': translate('BiblesPlugin','Proverbs'), - u'Eccl': translate('BiblesPlugin','Ecclesiastes'), - u'Song': translate('BiblesPlugin','Song of Solomon'), - u'Isa': translate('BiblesPlugin','Isaiah'), - u'Jer': translate('BiblesPlugin','Jeremiah'), - u'Lam': translate('BiblesPlugin','Lamentations'), - u'Ezek': translate('BiblesPlugin','Ezekiel'), - u'Dan': translate('BiblesPlugin','Daniel'), - u'Hos': translate('BiblesPlugin','Hosea'), - u'Joel': translate('BiblesPlugin','Joel'), - u'Amos': translate('BiblesPlugin','Amos'), - u'Obad': translate('BiblesPlugin','Obadiah'), - u'Jonah': translate('BiblesPlugin','Jonah'), - u'Mic': translate('BiblesPlugin','Micah'), - u'Nah': translate('BiblesPlugin','Nahum'), - u'Hab': translate('BiblesPlugin','Habakkuk'), - u'Zeph': translate('BiblesPlugin','Zephaniah'), - u'Hag': translate('BiblesPlugin','Haggai'), - u'Zech': translate('BiblesPlugin','Zechariah'), - u'Mal': translate('BiblesPlugin','Malachi'), - u'Matt': translate('BiblesPlugin','Matthew'), - u'Mark': translate('BiblesPlugin','Mark'), - u'Luke': translate('BiblesPlugin','Luke'), - u'John': translate('BiblesPlugin','John'), - u'Acts': translate('BiblesPlugin','Acts'), - u'Rom': translate('BiblesPlugin','Romans'), - u'1Cor': translate('BiblesPlugin','1 Corinthians'), - u'2Cor': translate('BiblesPlugin','2 Corinthians'), - u'Gal': translate('BiblesPlugin','Galatians'), - u'Eph': translate('BiblesPlugin','Ephesians'), - u'Phil': translate('BiblesPlugin','Philippians'), - u'Col': translate('BiblesPlugin','Colossians'), - u'1Thess': translate('BiblesPlugin','1 Thessalonians'), - u'2Thess': translate('BiblesPlugin','2 Thessalonians'), - u'1Tim': translate('BiblesPlugin','1 Timothy'), - u'2Tim': translate('BiblesPlugin','2 Timothy'), - u'Titus': translate('BiblesPlugin','Titus'), - u'Phlm': translate('BiblesPlugin','Philemon'), - u'Heb': translate('BiblesPlugin','Hebrews'), - u'Jas': translate('BiblesPlugin','James'), - u'1Pet': translate('BiblesPlugin','1 Peter'), - u'2Pet': translate('BiblesPlugin','2 Peter'), - u'1John': translate('BiblesPlugin','1 John'), - u'2John': translate('BiblesPlugin','2 John'), - u'3John': translate('BiblesPlugin','3 John'), - u'Jude': translate('BiblesPlugin','Jude'), - u'Rev': translate('BiblesPlugin','Revelation'), - u'Jdt': translate('BiblesPlugin','Judith'), - u'Wis': translate('BiblesPlugin','Wisdom'), - u'Tob': translate('BiblesPlugin','Tobit'), - u'Sir': translate('BiblesPlugin','Sirach'), - u'Bar': translate('BiblesPlugin','Baruch'), - u'1Macc': translate('BiblesPlugin','1 Maccabees'), - u'2Macc': translate('BiblesPlugin','2 Maccabees'), - u'3Macc': translate('BiblesPlugin','3 Maccabees'), - u'4Macc': translate('BiblesPlugin','4 Maccabees'), - u'AddDan': translate('BiblesPlugin','Rest of Daniel'), - u'AddEsth': translate('BiblesPlugin','Rest of Esther'), - u'PrMan': translate('BiblesPlugin','Prayer of Manasses'), - u'LetJer': translate('BiblesPlugin','Letter of Jeremiah'), - u'PrAza': translate('BiblesPlugin','Prayer of Azariah'), - u'Sus': translate('BiblesPlugin','Susanna'), - u'Bel': translate('BiblesPlugin','Bel'), - u'1Esdr': translate('BiblesPlugin','1 Esdras'), - u'2Esdr': translate('BiblesPlugin','2 Esdras') + u'Gen': translate('BiblesPlugin', 'Genesis'), + u'Exod': translate('BiblesPlugin', 'Exodus'), + u'Lev': translate('BiblesPlugin', 'Leviticus'), + u'Num': translate('BiblesPlugin', 'Numbers'), + u'Deut': translate('BiblesPlugin', 'Deuteronomy'), + u'Josh': translate('BiblesPlugin', 'Joshua'), + u'Judg': translate('BiblesPlugin', 'Judges'), + u'Ruth': translate('BiblesPlugin', 'Ruth'), + u'1Sam': translate('BiblesPlugin', '1 Samuel'), + u'2Sam': translate('BiblesPlugin', '2 Samuel'), + u'1Kgs': translate('BiblesPlugin', '1 Kings'), + u'2Kgs': translate('BiblesPlugin', '2 Kings'), + u'1Chr': translate('BiblesPlugin', '1 Chronicles'), + u'2Chr': translate('BiblesPlugin', '2 Chronicles'), + u'Esra': translate('BiblesPlugin', 'Ezra'), + u'Neh': translate('BiblesPlugin', 'Nehemiah'), + u'Esth': translate('BiblesPlugin', 'Esther'), + u'Job': translate('BiblesPlugin', 'Job'), + u'Ps': translate('BiblesPlugin', 'Psalms'), + u'Prov': translate('BiblesPlugin', 'Proverbs'), + u'Eccl': translate('BiblesPlugin', 'Ecclesiastes'), + u'Song': translate('BiblesPlugin', 'Song of Solomon'), + u'Isa': translate('BiblesPlugin', 'Isaiah'), + u'Jer': translate('BiblesPlugin', 'Jeremiah'), + u'Lam': translate('BiblesPlugin', 'Lamentations'), + u'Ezek': translate('BiblesPlugin', 'Ezekiel'), + u'Dan': translate('BiblesPlugin', 'Daniel'), + u'Hos': translate('BiblesPlugin', 'Hosea'), + u'Joel': translate('BiblesPlugin', 'Joel'), + u'Amos': translate('BiblesPlugin', 'Amos'), + u'Obad': translate('BiblesPlugin', 'Obadiah'), + u'Jonah': translate('BiblesPlugin', 'Jonah'), + u'Mic': translate('BiblesPlugin', 'Micah'), + u'Nah': translate('BiblesPlugin', 'Nahum'), + u'Hab': translate('BiblesPlugin', 'Habakkuk'), + u'Zeph': translate('BiblesPlugin', 'Zephaniah'), + u'Hag': translate('BiblesPlugin', 'Haggai'), + u'Zech': translate('BiblesPlugin', 'Zechariah'), + u'Mal': translate('BiblesPlugin', 'Malachi'), + u'Matt': translate('BiblesPlugin', 'Matthew'), + u'Mark': translate('BiblesPlugin', 'Mark'), + u'Luke': translate('BiblesPlugin', 'Luke'), + u'John': translate('BiblesPlugin', 'John'), + u'Acts': translate('BiblesPlugin', 'Acts'), + u'Rom': translate('BiblesPlugin', 'Romans'), + u'1Cor': translate('BiblesPlugin', '1 Corinthians'), + u'2Cor': translate('BiblesPlugin', '2 Corinthians'), + u'Gal': translate('BiblesPlugin', 'Galatians'), + u'Eph': translate('BiblesPlugin', 'Ephesians'), + u'Phil': translate('BiblesPlugin', 'Philippians'), + u'Col': translate('BiblesPlugin', 'Colossians'), + u'1Thess': translate('BiblesPlugin', '1 Thessalonians'), + u'2Thess': translate('BiblesPlugin', '2 Thessalonians'), + u'1Tim': translate('BiblesPlugin', '1 Timothy'), + u'2Tim': translate('BiblesPlugin', '2 Timothy'), + u'Titus': translate('BiblesPlugin', 'Titus'), + u'Phlm': translate('BiblesPlugin', 'Philemon'), + u'Heb': translate('BiblesPlugin', 'Hebrews'), + u'Jas': translate('BiblesPlugin', 'James'), + u'1Pet': translate('BiblesPlugin', '1 Peter'), + u'2Pet': translate('BiblesPlugin', '2 Peter'), + u'1John': translate('BiblesPlugin', '1 John'), + u'2John': translate('BiblesPlugin', '2 John'), + u'3John': translate('BiblesPlugin', '3 John'), + u'Jude': translate('BiblesPlugin', 'Jude'), + u'Rev': translate('BiblesPlugin', 'Revelation'), + u'Jdt': translate('BiblesPlugin', 'Judith'), + u'Wis': translate('BiblesPlugin', 'Wisdom'), + u'Tob': translate('BiblesPlugin', 'Tobit'), + u'Sir': translate('BiblesPlugin', 'Sirach'), + u'Bar': translate('BiblesPlugin', 'Baruch'), + u'1Macc': translate('BiblesPlugin', '1 Maccabees'), + u'2Macc': translate('BiblesPlugin', '2 Maccabees'), + u'3Macc': translate('BiblesPlugin', '3 Maccabees'), + u'4Macc': translate('BiblesPlugin', '4 Maccabees'), + u'AddDan': translate('BiblesPlugin', 'Rest of Daniel'), + u'AddEsth': translate('BiblesPlugin', 'Rest of Esther'), + u'PrMan': translate('BiblesPlugin', 'Prayer of Manasses'), + u'LetJer': translate('BiblesPlugin', 'Letter of Jeremiah'), + u'PrAza': translate('BiblesPlugin', 'Prayer of Azariah'), + u'Sus': translate('BiblesPlugin', 'Susanna'), + u'Bel': translate('BiblesPlugin', 'Bel'), + u'1Esdr': translate('BiblesPlugin', '1 Esdras'), + u'2Esdr': translate('BiblesPlugin', '2 Esdras') } diff --git a/openlp/plugins/bibles/lib/biblestab.py b/openlp/plugins/bibles/lib/biblestab.py index c7028b577..09d340ad4 100644 --- a/openlp/plugins/bibles/lib/biblestab.py +++ b/openlp/plugins/bibles/lib/biblestab.py @@ -279,9 +279,8 @@ class BiblesTab(SettingsTab): self.languageSelectionGroupBox.setTitle( translate('BiblesPlugin.BiblesTab', 'Preferred Bookname Language')) self.languageSelectionLabel.setText(translate('BiblesPlugin.BiblesTab', - 'Choose the language in which the book names of the\nbible should ' - 'be displayed in advanced search or on\nautocompleter in quick ' - 'search:')) + 'Choose the language in which the book names of the\nBible should ' + 'be displayed in the Bible search:')) self.languageSelectionComboBox.setItemText(LanguageSelection.Bible, translate('BiblesPlugin.BiblesTab', 'Bible language')) self.languageSelectionComboBox.setItemText( @@ -291,9 +290,9 @@ class BiblesTab(SettingsTab): translate('BiblesPlugin.BiblesTab', 'English')) self.languageSelectionComboBox.setToolTip( translate('BiblesPlugin.BiblesTab', 'Multiple options:\n ' - 'Bible language - the language in which the bible book names ' - 'was imported\n Application language - the language you have ' - 'choosen for Openlp\n English - use always English booknames')) + 'Bible language - the language in which the Bible book names ' + 'were imported\n Application language - the language you have ' + 'chosen for OpenLP\n English - always use English book names')) def onBibleThemeComboBoxChanged(self): self.bible_theme = self.bibleThemeComboBox.currentText() diff --git a/openlp/plugins/bibles/lib/db.py b/openlp/plugins/bibles/lib/db.py index b419bebc0..c6c2ddac6 100644 --- a/openlp/plugins/bibles/lib/db.py +++ b/openlp/plugins/bibles/lib/db.py @@ -609,7 +609,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager): books = BiblesResourcesDB.run_sql(u'SELECT id, testament_id, name, ' u'abbreviation, chapters FROM book_reference WHERE ' u'LOWER(name) LIKE ? OR LOWER(abbreviation) LIKE ?', - (u'%'+string.lower()+u'%', u'%'+string.lower()+u'%')) + (u'%' + string.lower() + u'%', u'%' + string.lower() + u'%')) if books: return [ {