sync gramps34's _Date_sr.py with gramps41's _date_sr.py
This commit is contained in:
parent
320bbeb0b6
commit
e398d3db2d
@ -16,10 +16,7 @@
|
|||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
#
|
|
||||||
# DateHandler/_Date_sr.py
|
|
||||||
# $Id$
|
|
||||||
#
|
#
|
||||||
|
|
||||||
# Serbian version by Vlada Perić <vlada.peric@gmail.com>, 2009.
|
# Serbian version by Vlada Perić <vlada.peric@gmail.com>, 2009.
|
||||||
@ -28,7 +25,7 @@
|
|||||||
"""
|
"""
|
||||||
Serbian-specific classes for parsing and displaying dates.
|
Serbian-specific classes for parsing and displaying dates.
|
||||||
"""
|
"""
|
||||||
|
from __future__ import unicode_literals
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Python modules
|
# Python modules
|
||||||
@ -57,153 +54,153 @@ class DateParserSR(DateParser):
|
|||||||
"""
|
"""
|
||||||
month_to_int = DateParser.month_to_int
|
month_to_int = DateParser.month_to_int
|
||||||
|
|
||||||
month_to_int[u"januar"] = 1
|
month_to_int["januar"] = 1
|
||||||
month_to_int[u"januara"] = 1
|
month_to_int["januara"] = 1
|
||||||
month_to_int[u"jan"] = 1
|
month_to_int["jan"] = 1
|
||||||
month_to_int[u"јан"] = 1
|
month_to_int["јан"] = 1
|
||||||
month_to_int[u"јануара"] = 1
|
month_to_int["јануара"] = 1
|
||||||
month_to_int[u"јануар"] = 1
|
month_to_int["јануар"] = 1
|
||||||
month_to_int[u"i"] = 1
|
month_to_int["i"] = 1
|
||||||
|
|
||||||
month_to_int[u"februar"] = 2
|
month_to_int["februar"] = 2
|
||||||
month_to_int[u"februara"] = 2
|
month_to_int["februara"] = 2
|
||||||
month_to_int[u"feb"] = 2
|
month_to_int["feb"] = 2
|
||||||
month_to_int[u"феб"] = 2
|
month_to_int["феб"] = 2
|
||||||
month_to_int[u"фебруар"] = 2
|
month_to_int["фебруар"] = 2
|
||||||
month_to_int[u"фебруара"] = 2
|
month_to_int["фебруара"] = 2
|
||||||
month_to_int[u"ii"] = 2
|
month_to_int["ii"] = 2
|
||||||
|
|
||||||
month_to_int[u"mart"] = 3
|
month_to_int["mart"] = 3
|
||||||
month_to_int[u"marta"] = 3
|
month_to_int["marta"] = 3
|
||||||
month_to_int[u"mar"] = 3
|
month_to_int["mar"] = 3
|
||||||
month_to_int[u"мар"] = 3
|
month_to_int["мар"] = 3
|
||||||
month_to_int[u"март"] = 3
|
month_to_int["март"] = 3
|
||||||
month_to_int[u"марта"] = 3
|
month_to_int["марта"] = 3
|
||||||
month_to_int[u"iii"] = 3
|
month_to_int["iii"] = 3
|
||||||
|
|
||||||
month_to_int[u"april"] = 4
|
month_to_int["april"] = 4
|
||||||
month_to_int[u"aprila"] = 4
|
month_to_int["aprila"] = 4
|
||||||
month_to_int[u"apr"] = 4
|
month_to_int["apr"] = 4
|
||||||
month_to_int[u"апр"] = 4
|
month_to_int["апр"] = 4
|
||||||
month_to_int[u"април"] = 4
|
month_to_int["април"] = 4
|
||||||
month_to_int[u"априла"] = 4
|
month_to_int["априла"] = 4
|
||||||
month_to_int[u"iv"] = 4
|
month_to_int["iv"] = 4
|
||||||
|
|
||||||
month_to_int[u"maj"] = 5
|
month_to_int["maj"] = 5
|
||||||
month_to_int[u"maja"] = 5
|
month_to_int["maja"] = 5
|
||||||
month_to_int[u"мај"] = 5
|
month_to_int["мај"] = 5
|
||||||
month_to_int[u"маја"] = 5
|
month_to_int["маја"] = 5
|
||||||
month_to_int[u"v"] = 5
|
month_to_int["v"] = 5
|
||||||
|
|
||||||
month_to_int[u"jun"] = 6
|
month_to_int["jun"] = 6
|
||||||
month_to_int[u"juna"] = 6
|
month_to_int["juna"] = 6
|
||||||
month_to_int[u"јун"] = 6
|
month_to_int["јун"] = 6
|
||||||
month_to_int[u"јуна"] = 6
|
month_to_int["јуна"] = 6
|
||||||
month_to_int[u"vi"] = 6
|
month_to_int["vi"] = 6
|
||||||
|
|
||||||
month_to_int[u"jul"] = 7
|
month_to_int["jul"] = 7
|
||||||
month_to_int[u"jula"] = 7
|
month_to_int["jula"] = 7
|
||||||
month_to_int[u"јул"] = 7
|
month_to_int["јул"] = 7
|
||||||
month_to_int[u"јула"] = 7
|
month_to_int["јула"] = 7
|
||||||
month_to_int[u"vii"] = 7
|
month_to_int["vii"] = 7
|
||||||
|
|
||||||
month_to_int[u"avgust"] = 8
|
month_to_int["avgust"] = 8
|
||||||
month_to_int[u"avgusta"] = 8
|
month_to_int["avgusta"] = 8
|
||||||
month_to_int[u"avg"] = 8
|
month_to_int["avg"] = 8
|
||||||
month_to_int[u"авг"] = 8
|
month_to_int["авг"] = 8
|
||||||
month_to_int[u"август"] = 8
|
month_to_int["август"] = 8
|
||||||
month_to_int[u"августа"] = 8
|
month_to_int["августа"] = 8
|
||||||
month_to_int[u"viii"] = 8
|
month_to_int["viii"] = 8
|
||||||
|
|
||||||
month_to_int[u"septembar"] = 9
|
month_to_int["septembar"] = 9
|
||||||
month_to_int[u"septembra"] = 9
|
month_to_int["septembra"] = 9
|
||||||
month_to_int[u"sep"] = 9
|
month_to_int["sep"] = 9
|
||||||
month_to_int[u"сеп"] = 9
|
month_to_int["сеп"] = 9
|
||||||
month_to_int[u"септембар"] = 9
|
month_to_int["септембар"] = 9
|
||||||
month_to_int[u"септембра"] = 9
|
month_to_int["септембра"] = 9
|
||||||
month_to_int[u"ix"] = 9
|
month_to_int["ix"] = 9
|
||||||
|
|
||||||
month_to_int[u"oktobar"] = 10
|
month_to_int["oktobar"] = 10
|
||||||
month_to_int[u"oktobra"] = 10
|
month_to_int["oktobra"] = 10
|
||||||
month_to_int[u"okt"] = 10
|
month_to_int["okt"] = 10
|
||||||
month_to_int[u"окт"] = 10
|
month_to_int["окт"] = 10
|
||||||
month_to_int[u"октобар"] = 10
|
month_to_int["октобар"] = 10
|
||||||
month_to_int[u"октобра"] = 10
|
month_to_int["октобра"] = 10
|
||||||
month_to_int[u"x"] = 10
|
month_to_int["x"] = 10
|
||||||
|
|
||||||
month_to_int[u"novembar"] = 11
|
month_to_int["novembar"] = 11
|
||||||
month_to_int[u"novembra"] = 11
|
month_to_int["novembra"] = 11
|
||||||
month_to_int[u"nov"] = 11
|
month_to_int["nov"] = 11
|
||||||
month_to_int[u"нов"] = 11
|
month_to_int["нов"] = 11
|
||||||
month_to_int[u"новембар"] = 11
|
month_to_int["новембар"] = 11
|
||||||
month_to_int[u"новембра"] = 11
|
month_to_int["новембра"] = 11
|
||||||
month_to_int[u"xi"] = 11
|
month_to_int["xi"] = 11
|
||||||
|
|
||||||
month_to_int[u"decembar"] = 12
|
month_to_int["decembar"] = 12
|
||||||
month_to_int[u"decembra"] = 12
|
month_to_int["decembra"] = 12
|
||||||
month_to_int[u"dec"] = 12
|
month_to_int["dec"] = 12
|
||||||
month_to_int[u"дец"] = 12
|
month_to_int["дец"] = 12
|
||||||
month_to_int[u"децембар"] = 12
|
month_to_int["децембар"] = 12
|
||||||
month_to_int[u"децембра"] = 12
|
month_to_int["децембра"] = 12
|
||||||
month_to_int[u"xii"] = 12
|
month_to_int["xii"] = 12
|
||||||
|
|
||||||
modifier_to_int = {
|
modifier_to_int = {
|
||||||
u'pre' : Date.MOD_BEFORE,
|
'pre' : Date.MOD_BEFORE,
|
||||||
u'posle' : Date.MOD_AFTER,
|
'posle' : Date.MOD_AFTER,
|
||||||
u'oko' : Date.MOD_ABOUT,
|
'oko' : Date.MOD_ABOUT,
|
||||||
u'cca' : Date.MOD_ABOUT,
|
'cca' : Date.MOD_ABOUT,
|
||||||
|
|
||||||
u'пре' : Date.MOD_BEFORE,
|
'пре' : Date.MOD_BEFORE,
|
||||||
u'после' : Date.MOD_AFTER,
|
'после' : Date.MOD_AFTER,
|
||||||
u'око' : Date.MOD_ABOUT,
|
'око' : Date.MOD_ABOUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
calendar_to_int = {
|
calendar_to_int = {
|
||||||
u'gregorijanski' : Date.CAL_GREGORIAN,
|
'gregorijanski' : Date.CAL_GREGORIAN,
|
||||||
u'greg.' : Date.CAL_GREGORIAN,
|
'greg.' : Date.CAL_GREGORIAN,
|
||||||
u'julijanski' : Date.CAL_JULIAN,
|
'julijanski' : Date.CAL_JULIAN,
|
||||||
u'jul.' : Date.CAL_JULIAN,
|
'jul.' : Date.CAL_JULIAN,
|
||||||
u'hebrejski' : Date.CAL_HEBREW,
|
'hebrejski' : Date.CAL_HEBREW,
|
||||||
u'hebr.' : Date.CAL_HEBREW,
|
'hebr.' : Date.CAL_HEBREW,
|
||||||
u'islamski' : Date.CAL_ISLAMIC,
|
'islamski' : Date.CAL_ISLAMIC,
|
||||||
u'isl.' : Date.CAL_ISLAMIC,
|
'isl.' : Date.CAL_ISLAMIC,
|
||||||
u'francuski republikanski': Date.CAL_FRENCH,
|
'francuski republikanski': Date.CAL_FRENCH,
|
||||||
u'franc.' : Date.CAL_FRENCH,
|
'franc.' : Date.CAL_FRENCH,
|
||||||
u'persijski' : Date.CAL_PERSIAN,
|
'persijski' : Date.CAL_PERSIAN,
|
||||||
u'pers. ' : Date.CAL_PERSIAN,
|
'pers. ' : Date.CAL_PERSIAN,
|
||||||
u'švedski' : Date.CAL_SWEDISH,
|
'švedski' : Date.CAL_SWEDISH,
|
||||||
u'šv.' : Date.CAL_SWEDISH,
|
'šv.' : Date.CAL_SWEDISH,
|
||||||
|
|
||||||
u'грегоријански' : Date.CAL_GREGORIAN,
|
'грегоријански' : Date.CAL_GREGORIAN,
|
||||||
u'грег.' : Date.CAL_GREGORIAN,
|
'грег.' : Date.CAL_GREGORIAN,
|
||||||
u'јулијански' : Date.CAL_JULIAN,
|
'јулијански' : Date.CAL_JULIAN,
|
||||||
u'јул.' : Date.CAL_JULIAN,
|
'јул.' : Date.CAL_JULIAN,
|
||||||
u'хебрејски' : Date.CAL_HEBREW,
|
'хебрејски' : Date.CAL_HEBREW,
|
||||||
u'хебр.' : Date.CAL_HEBREW,
|
'хебр.' : Date.CAL_HEBREW,
|
||||||
u'исламски' : Date.CAL_ISLAMIC,
|
'исламски' : Date.CAL_ISLAMIC,
|
||||||
u'исл.' : Date.CAL_ISLAMIC,
|
'исл.' : Date.CAL_ISLAMIC,
|
||||||
u'француски републикански': Date.CAL_FRENCH,
|
'француски републикански': Date.CAL_FRENCH,
|
||||||
u'франц.' : Date.CAL_FRENCH,
|
'франц.' : Date.CAL_FRENCH,
|
||||||
u'персијски' : Date.CAL_PERSIAN,
|
'персијски' : Date.CAL_PERSIAN,
|
||||||
u'перс. ' : Date.CAL_PERSIAN,
|
'перс. ' : Date.CAL_PERSIAN,
|
||||||
u'шведски' : Date.CAL_SWEDISH,
|
'шведски' : Date.CAL_SWEDISH,
|
||||||
u'шв' : Date.CAL_SWEDISH,
|
'шв' : Date.CAL_SWEDISH,
|
||||||
}
|
}
|
||||||
|
|
||||||
quality_to_int = {
|
quality_to_int = {
|
||||||
u'procenjeno' : Date.QUAL_ESTIMATED,
|
'procenjeno' : Date.QUAL_ESTIMATED,
|
||||||
u'pro.' : Date.QUAL_ESTIMATED,
|
'pro.' : Date.QUAL_ESTIMATED,
|
||||||
u'izračunato' : Date.QUAL_CALCULATED,
|
'izračunato' : Date.QUAL_CALCULATED,
|
||||||
u'izr.' : Date.QUAL_CALCULATED,
|
'izr.' : Date.QUAL_CALCULATED,
|
||||||
|
|
||||||
u'процењено' : Date.QUAL_ESTIMATED,
|
'процењено' : Date.QUAL_ESTIMATED,
|
||||||
u'про.' : Date.QUAL_ESTIMATED,
|
'про.' : Date.QUAL_ESTIMATED,
|
||||||
u'израчунато' : Date.QUAL_CALCULATED,
|
'израчунато' : Date.QUAL_CALCULATED,
|
||||||
u'изр.' : Date.QUAL_CALCULATED,
|
'изр.' : Date.QUAL_CALCULATED,
|
||||||
}
|
}
|
||||||
|
|
||||||
bce = [u"пре нове ере", u"пре Христа", u"п.н.е."
|
bce = ["пре нове ере", "пре Христа", "п.н.е."
|
||||||
u"pre nove ere", u"pre Hrista", u"p.n.e."] + DateParser.bce
|
"pre nove ere", "pre Hrista", "p.n.e."] + DateParser.bce
|
||||||
|
|
||||||
def init_strings(self):
|
def init_strings(self):
|
||||||
"""
|
"""
|
||||||
@ -217,10 +214,10 @@ class DateParserSR(DateParser):
|
|||||||
# match Day.Month.Year.
|
# match Day.Month.Year.
|
||||||
self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\.?$")
|
self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\.?$")
|
||||||
|
|
||||||
_span_1 = [u'od', u'од']
|
_span_1 = ['od', 'од']
|
||||||
_span_2 = [u'do', u'до']
|
_span_2 = ['do', 'до']
|
||||||
_range_1 = [u'između', u'између']
|
_range_1 = ['između', 'између']
|
||||||
_range_2 = [u'i', u'и']
|
_range_2 = ['i', 'и']
|
||||||
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
||||||
('|'.join(_span_1), '|'.join(_span_2)),
|
('|'.join(_span_1), '|'.join(_span_2)),
|
||||||
re.IGNORECASE)
|
re.IGNORECASE)
|
||||||
@ -238,14 +235,14 @@ class DateDisplaySR_latin(DateDisplay):
|
|||||||
Serbian (latin) date display class
|
Serbian (latin) date display class
|
||||||
"""
|
"""
|
||||||
long_months = ("",
|
long_months = ("",
|
||||||
u"januara", u"februara", u"marta", u"aprila",
|
"januara", "februara", "marta", "aprila",
|
||||||
u"maja", u"juna", u"jula", u"avgusta",
|
"maja", "juna", "jula", "avgusta",
|
||||||
u"septembra", u"oktobra", u"novembra", u"decembra"
|
"septembra", "oktobra", "novembra", "decembra"
|
||||||
)
|
)
|
||||||
|
|
||||||
short_months = ("",
|
short_months = ("",
|
||||||
u"jan", u"feb", u"mar", u"apr", u"maj", u"jun",
|
"jan", "feb", "mar", "apr", "maj", "jun",
|
||||||
u"jul", u"avg", u"sep", u"okt", u"nov", u"dec"
|
"jul", "avg", "sep", "okt", "nov", "dec"
|
||||||
)
|
)
|
||||||
|
|
||||||
roman_months = (
|
roman_months = (
|
||||||
@ -254,9 +251,9 @@ class DateDisplaySR_latin(DateDisplay):
|
|||||||
)
|
)
|
||||||
|
|
||||||
calendar = (
|
calendar = (
|
||||||
"", u"julijanski", u"hebrejski",
|
"", "julijanski", "hebrejski",
|
||||||
u"francuski republikanski", u"persijski", u"islamski",
|
"francuski republikanski", "persijski", "islamski",
|
||||||
u"švedski"
|
"švedski"
|
||||||
)
|
)
|
||||||
|
|
||||||
_mod_str = ("", "pre ", "posle ", "oko ", "", "", "")
|
_mod_str = ("", "pre ", "posle ", "oko ", "", "", "")
|
||||||
@ -299,27 +296,27 @@ class DateDisplaySR_latin(DateDisplay):
|
|||||||
# day. month_abbreviation year.
|
# day. month_abbreviation year.
|
||||||
if date_val[0] == 0:
|
if date_val[0] == 0:
|
||||||
if date_val[1] == 0:
|
if date_val[1] == 0:
|
||||||
value = u"%s." % year
|
value = "%s." % year
|
||||||
else:
|
else:
|
||||||
value = u"%s %s." % (self.short_months[date_val[1]], year)
|
value = "%s %s." % (self.short_months[date_val[1]], year)
|
||||||
else:
|
else:
|
||||||
value = u"%d. %s %s." % (date_val[0],
|
value = "%d. %s %s." % (date_val[0],
|
||||||
self.short_months[date_val[1]], year)
|
self.short_months[date_val[1]], year)
|
||||||
elif self.format == 3:
|
elif self.format == 3:
|
||||||
# day. month_name year.
|
# day. month_name year.
|
||||||
if date_val[0] == 0:
|
if date_val[0] == 0:
|
||||||
if date_val[1] == 0:
|
if date_val[1] == 0:
|
||||||
value = u"%s." % year
|
value = "%s." % year
|
||||||
else:
|
else:
|
||||||
value = u"%s %s." % (self.long_months[date_val[1]], year)
|
value = "%s %s." % (self.long_months[date_val[1]], year)
|
||||||
else:
|
else:
|
||||||
value = u"%d. %s %s." % (date_val[0],
|
value = "%d. %s %s." % (date_val[0],
|
||||||
self.long_months[date_val[1]], year)
|
self.long_months[date_val[1]], year)
|
||||||
else:
|
else:
|
||||||
# day. Roman_number_month year.
|
# day. Roman_number_month year.
|
||||||
if date_val[0] == 0:
|
if date_val[0] == 0:
|
||||||
if date_val[1] == 0:
|
if date_val[1] == 0:
|
||||||
value = u"%s." % year
|
value = "%s." % year
|
||||||
else:
|
else:
|
||||||
value = "%s %s." % (self.roman_months[date_val[1]], year)
|
value = "%s %s." % (self.roman_months[date_val[1]], year)
|
||||||
else:
|
else:
|
||||||
@ -350,13 +347,13 @@ class DateDisplaySR_latin(DateDisplay):
|
|||||||
d_1 = self.display_cal[cal](start)
|
d_1 = self.display_cal[cal](start)
|
||||||
d_2 = self.display_cal[cal](date.get_stop_date())
|
d_2 = self.display_cal[cal](date.get_stop_date())
|
||||||
scal = self.format_extras(cal, newyear)
|
scal = self.format_extras(cal, newyear)
|
||||||
return "%s%s %s %s %s%s" % (qual_str, u'od', d_1, u'do', d_2,
|
return "%s%s %s %s %s%s" % (qual_str, 'od', d_1, 'do', d_2,
|
||||||
scal)
|
scal)
|
||||||
elif mod == Date.MOD_RANGE:
|
elif mod == Date.MOD_RANGE:
|
||||||
d_1 = self.display_cal[cal](start)
|
d_1 = self.display_cal[cal](start)
|
||||||
d_2 = self.display_cal[cal](date.get_stop_date())
|
d_2 = self.display_cal[cal](date.get_stop_date())
|
||||||
scal = self.format_extras(cal, newyear)
|
scal = self.format_extras(cal, newyear)
|
||||||
return "%s%s %s %s %s%s" % (qual_str, u'između', d_1, u'i', d_2,
|
return "%s%s %s %s %s%s" % (qual_str, 'između', d_1, 'i', d_2,
|
||||||
scal)
|
scal)
|
||||||
else:
|
else:
|
||||||
text = self.display_cal[date.get_calendar()](start)
|
text = self.display_cal[date.get_calendar()](start)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user