forked from openlp/openlp
- remove FIXME: comment
- change scripture reference configuration tooltip strings to allow separate translation - fix RegEx for scripture references with trailing list separator
This commit is contained in:
parent
cac10059f3
commit
d6ecab7a04
@ -65,14 +65,16 @@ def update_reference_separators():
|
|||||||
references.
|
references.
|
||||||
"""
|
"""
|
||||||
default_separators = unicode(translate('BiblesPlugin',
|
default_separators = unicode(translate('BiblesPlugin',
|
||||||
':|v|V|verse;;-|to;;,|and;;end',
|
':|v|V|verse|verses;;-|to;;,|and;;end',
|
||||||
'This are 4 values seperated each by two semicolons representing the '
|
'This are 4 values seperated each by two semicolons representing the '
|
||||||
'seperators for parsing references. This values are verse separators, '
|
'seperators for parsing references. This values are verse separators, '
|
||||||
'range separators, list separators and end mark. Alternative values '
|
'range separators, list separators and end mark. Alternative values '
|
||||||
'to be seperated by a vertical bar "|". In this case the first value '
|
'to be seperated by a vertical bar "|". In this case the first value '
|
||||||
'is the default and used for the display format.')).split(u';;')
|
'is the default and used for the display format. If a semicolon should '
|
||||||
|
'be used you have to give an alternative separator afterwards to allow '
|
||||||
|
'OpenLP correct splitting of the translation.')).split(u';;')
|
||||||
settings = QtCore.QSettings()
|
settings = QtCore.QSettings()
|
||||||
settings.beginGroup(u'bibles') # FIXME: get the name from somewere else
|
settings.beginGroup(u'bibles')
|
||||||
custom_separators = [
|
custom_separators = [
|
||||||
unicode(settings.value(u'verse separator',
|
unicode(settings.value(u'verse separator',
|
||||||
QtCore.QVariant(u'')).toString()),
|
QtCore.QVariant(u'')).toString()),
|
||||||
@ -104,18 +106,19 @@ def update_reference_separators():
|
|||||||
REFERENCE_SEPARATORS[u'sep_%s_default' % role] = \
|
REFERENCE_SEPARATORS[u'sep_%s_default' % role] = \
|
||||||
default_separators[index]
|
default_separators[index]
|
||||||
# verse range match: (<chapter>:)?<verse>(-((<chapter>:)?<verse>|end)?)?
|
# verse range match: (<chapter>:)?<verse>(-((<chapter>:)?<verse>|end)?)?
|
||||||
range_string = u'(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?' \
|
range_regex = u'(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?' \
|
||||||
u'(?P<from_verse>[0-9]+)(?P<range_to>%(sep_r)s(?:(?:(?P<to_chapter>' \
|
u'(?P<from_verse>[0-9]+)(?P<range_to>%(sep_r)s(?:(?:(?P<to_chapter>' \
|
||||||
u'[0-9]+)%(sep_v)s)?(?P<to_verse>[0-9]+)|%(sep_e)s)?)?' % \
|
u'[0-9]+)%(sep_v)s)?(?P<to_verse>[0-9]+)|%(sep_e)s)?)?' % \
|
||||||
REFERENCE_SEPARATORS
|
REFERENCE_SEPARATORS
|
||||||
REFERENCE_MATCHES[u'range'] = re.compile(u'^\s*%s\s*$' % range_string,
|
REFERENCE_MATCHES[u'range'] = re.compile(u'^\s*%s\s*$' % range_regex,
|
||||||
re.UNICODE)
|
re.UNICODE)
|
||||||
REFERENCE_MATCHES[u'range_separator'] = re.compile(
|
REFERENCE_MATCHES[u'range_separator'] = re.compile(
|
||||||
REFERENCE_SEPARATORS[u'sep_l'], re.UNICODE)
|
REFERENCE_SEPARATORS[u'sep_l'], re.UNICODE)
|
||||||
# full reference match: <book>(<range>(,|(?=$)))+
|
# full reference match: <book>(<range>(,|(?=$)))+
|
||||||
REFERENCE_MATCHES[u'full'] = re.compile(u'^\s*(?!\s)(?P<book>[\d]*[^\d]+)'
|
REFERENCE_MATCHES[u'full'] = re.compile(
|
||||||
u'(?<!\s)\s*(?P<ranges>(?:%(range)s(?:%(sep_l)s|(?=\s*$)))+)\s*$' % \
|
u'^\s*(?!\s)(?P<book>[\d]*[^\d]+)(?<!\s)\s*'
|
||||||
dict(REFERENCE_SEPARATORS.items() + [(u'range', range_string)]),
|
u'(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$' \
|
||||||
|
% dict(REFERENCE_SEPARATORS.items() + [(u'range_regex', range_regex)]),
|
||||||
re.UNICODE)
|
re.UNICODE)
|
||||||
|
|
||||||
def get_reference_separator(separator_type):
|
def get_reference_separator(separator_type):
|
||||||
@ -194,7 +197,7 @@ def parse_reference(reference):
|
|||||||
If there is a range separator without further verse declaration the last
|
If there is a range separator without further verse declaration the last
|
||||||
refered chapter is addressed until the end.
|
refered chapter is addressed until the end.
|
||||||
|
|
||||||
``range_string`` is a regular expression which matches for verse range
|
``range_regex`` is a regular expression which matches for verse range
|
||||||
declarations:
|
declarations:
|
||||||
|
|
||||||
``(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?``
|
``(?:(?P<from_chapter>[0-9]+)%(sep_v)s)?``
|
||||||
@ -223,9 +226,9 @@ def parse_reference(reference):
|
|||||||
are optional leading digits followed by non-digits. The group ends
|
are optional leading digits followed by non-digits. The group ends
|
||||||
before the whitspace in front of the next digit.
|
before the whitspace in front of the next digit.
|
||||||
|
|
||||||
``(?P<ranges>(?:`` + range_string + ``(?:%(sep_l)s|(?=\s*$)))+)\s*$``
|
``(?P<ranges>(?:%(range_regex)s(?:%(sep_l)s(?!\s*$)|(?=\s*$)))+)\s*$``
|
||||||
The second group contains all ``ranges``. This can be multiple
|
The second group contains all ``ranges``. This can be multiple
|
||||||
declarations of a range_string separated by a list separator.
|
declarations of range_regex separated by a list separator.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
log.debug(u'parse_reference("%s")', reference)
|
log.debug(u'parse_reference("%s")', reference)
|
||||||
|
@ -236,17 +236,17 @@ class BiblesTab(SettingsTab):
|
|||||||
translate('BiblesPlugin.BiblesTab', 'End Mark:'))
|
translate('BiblesPlugin.BiblesTab', 'End Mark:'))
|
||||||
self.verseSeparatorLineEdit.setToolTip(
|
self.verseSeparatorLineEdit.setToolTip(
|
||||||
translate('BiblesPlugin.BiblesTab', 'Multiple alternative '
|
translate('BiblesPlugin.BiblesTab', 'Multiple alternative '
|
||||||
'separators may be defined.\nThey have to be separated '
|
'verse separators may be defined.\nThey have to be separated '
|
||||||
'by a vertical bar "|".\nPlease clear this edit line to use '
|
'by a vertical bar "|".\nPlease clear this edit line to use '
|
||||||
'the default value.'))
|
'the default value.'))
|
||||||
self.rangeSeparatorLineEdit.setToolTip(
|
self.rangeSeparatorLineEdit.setToolTip(
|
||||||
translate('BiblesPlugin.BiblesTab', 'Multiple alternative '
|
translate('BiblesPlugin.BiblesTab', 'Multiple alternative '
|
||||||
'separators may be defined.\nThey have to be separated '
|
'range separators may be defined.\nThey have to be separated '
|
||||||
'by a vertical bar "|".\nPlease clear this edit line to use '
|
'by a vertical bar "|".\nPlease clear this edit line to use '
|
||||||
'the default value.'))
|
'the default value.'))
|
||||||
self.listSeparatorLineEdit.setToolTip(
|
self.listSeparatorLineEdit.setToolTip(
|
||||||
translate('BiblesPlugin.BiblesTab', 'Multiple alternative '
|
translate('BiblesPlugin.BiblesTab', 'Multiple alternative '
|
||||||
'separators may be defined.\nThey have to be separated '
|
'list separators may be defined.\nThey have to be separated '
|
||||||
'by a vertical bar "|".\nPlease clear this edit line to use '
|
'by a vertical bar "|".\nPlease clear this edit line to use '
|
||||||
'the default value.'))
|
'the default value.'))
|
||||||
self.endSeparatorLineEdit.setToolTip(
|
self.endSeparatorLineEdit.setToolTip(
|
||||||
|
Loading…
Reference in New Issue
Block a user