From d6746bb76b4633bc755156dc601803b7161f8830 Mon Sep 17 00:00:00 2001 From: Arjan Schrijver Date: Wed, 21 Aug 2013 22:14:11 +0200 Subject: [PATCH] Handle an unknown bible language nicely --- openlp/plugins/bibles/lib/osis.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/openlp/plugins/bibles/lib/osis.py b/openlp/plugins/bibles/lib/osis.py index 4bbad60dc..3c23e1c4a 100644 --- a/openlp/plugins/bibles/lib/osis.py +++ b/openlp/plugins/bibles/lib/osis.py @@ -148,11 +148,18 @@ class OSISBible(BibleDB): self.filename) return False book_details = BiblesResourcesDB.get_book_by_id(book_ref_id) - custom_translator = LanguageManager.get_translator( - BiblesResourcesDB.get_language_by_id( - language_id)['code'])[0] - book_name_localized = unicode(custom_translator.translate( - 'BiblesPlugin', book_details[u'name'])) + bible_language = BiblesResourcesDB.get_language_by_id(language_id) + if bible_language is not None: + # The language of this bible was found, so we can + # translate the name of this book + custom_translator = LanguageManager.get_translator( + bible_language['code'])[0] + book_name_localized = unicode(custom_translator.translate( + 'BiblesPlugin', book_details[u'name'])) + else: + # The language of this bible was not found, so we just + # use the English name for this book + book_name_localized = book_details[u'name'] if not db_book or db_book.name != book_name_localized: log.debug(u'New book: "%s"' % book_name_localized) db_book = self.create_book(