From c294ea5752ccdb55b3c3f81b478959474de6a081 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Tue, 7 Apr 2015 23:01:52 +0100 Subject: [PATCH] Make the way we display verse ranges consistent and make use of localized or custom separators. Fixes bug 1081807 Fixes: https://launchpad.net/bugs/1081807 --- openlp/plugins/bibles/lib/mediaitem.py | 2 +- .../plugins/bibles/lib/versereferencelist.py | 30 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/openlp/plugins/bibles/lib/mediaitem.py b/openlp/plugins/bibles/lib/mediaitem.py index d2b877b81..0d3a40008 100644 --- a/openlp/plugins/bibles/lib/mediaitem.py +++ b/openlp/plugins/bibles/lib/mediaitem.py @@ -849,7 +849,7 @@ class BibleMediaItem(MediaManagerItem): service_item.add_capability(ItemCapabilities.CanWordSplit) service_item.add_capability(ItemCapabilities.CanEditTitle) # Service Item: Title - service_item.title = create_separated_list(raw_title) + service_item.title = '%s %s' % (verses.format_verses(), verses.format_versions()) # Service Item: Theme if not self.settings.bible_theme: service_item.theme = None diff --git a/openlp/plugins/bibles/lib/versereferencelist.py b/openlp/plugins/bibles/lib/versereferencelist.py index a04617877..38496d956 100644 --- a/openlp/plugins/bibles/lib/versereferencelist.py +++ b/openlp/plugins/bibles/lib/versereferencelist.py @@ -20,6 +20,8 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### +from openlp.plugins.bibles.lib import get_reference_separator + class VerseReferenceList(object): """ @@ -53,29 +55,39 @@ class VerseReferenceList(object): self.version_list.append({'version': version, 'copyright': copyright, 'permission': permission}) def format_verses(self): + verse_sep = get_reference_separator('sep_v_display') + range_sep = get_reference_separator('sep_r_display') + list_sep = get_reference_separator('sep_l_display') result = '' for index, verse in enumerate(self.verse_list): if index == 0: - result = '%s %s:%s' % (verse['book'], verse['chapter'], verse['start']) + result = '%s %s%s%s' % (verse['book'], verse['chapter'], verse_sep, verse['start']) if verse['start'] != verse['end']: - result = '%s-%s' % (result, verse['end']) + result = '%s%s%s' % (result, range_sep, verse['end']) continue prev = index - 1 if self.verse_list[prev]['version'] != verse['version']: result = '%s (%s)' % (result, self.verse_list[prev]['version']) - result += ', ' + result += '%s ' % list_sep if self.verse_list[prev]['book'] != verse['book']: - result = '%s%s %s:' % (result, verse['book'], verse['chapter']) + result = '%s%s %s%s' % (result, verse['book'], verse['chapter'], verse_sep) elif self.verse_list[prev]['chapter'] != verse['chapter']: - result = '%s%s:' % (result, verse['chapter']) + result = '%s%s%s' % (result, verse['chapter'], verse_sep) result += str(verse['start']) if verse['start'] != verse['end']: - result = '%s-%s' % (result, verse['end']) + result = '%s%s%s' % (result, range_sep, verse['end']) if len(self.version_list) > 1: result = '%s (%s)' % (result, verse['version']) return result - def format_versions(self): + def format_versions(self, copyright=True, permission=True): + """ + Format a string with the bible versions used + + :param copyright: If the copyright info should be included, default is true. + :param permission: If the permission info should be included, default is true. + :return: A formatted string with the bible versions used + """ result = '' for index, version in enumerate(self.version_list): if index > 0: @@ -83,9 +95,9 @@ class VerseReferenceList(object): result += ';' result += ' ' result += version['version'] - if version['copyright'].strip(): + if copyright and version['copyright'].strip(): result += ', ' + version['copyright'] - if version['permission'].strip(): + if permission and version['permission'].strip(): result += ', ' + version['permission'] result = result.rstrip() if result.endswith(','):