merge changes from gramps20
svn: r5482
This commit is contained in:
@@ -59,7 +59,7 @@ class DateParserDE(DateParser):
|
||||
month_to_int[u"jenner"] = 1
|
||||
month_to_int[u"feber"] = 2
|
||||
month_to_int[u"februaris"] = 2
|
||||
month_to_int[u"merz"] = 2
|
||||
month_to_int[u"merz"] = 3
|
||||
month_to_int[u"aprilis"] = 4
|
||||
month_to_int[u"maius"] = 5
|
||||
month_to_int[u"junius"] = 6
|
||||
|
||||
@@ -58,15 +58,18 @@ class DateParserFI(DateParser):
|
||||
modifier_to_int = {
|
||||
# examples:
|
||||
# - ennen 1.1.2005
|
||||
# - 1.1.2005 jälkeen
|
||||
# - noin 1.1.2005
|
||||
u'ennen' : Date.MOD_BEFORE,
|
||||
u'e.' : Date.MOD_BEFORE,
|
||||
u'jälkeen' : Date.MOD_AFTER,
|
||||
u'j.' : Date.MOD_AFTER,
|
||||
u'noin' : Date.MOD_ABOUT,
|
||||
u'n.' : Date.MOD_ABOUT,
|
||||
}
|
||||
modifier_after_to_int = {
|
||||
# examples:
|
||||
# - 1.1.2005 jälkeen
|
||||
u'jälkeen' : Date.MOD_AFTER,
|
||||
u'j.' : Date.MOD_AFTER,
|
||||
}
|
||||
|
||||
bce = ["ekr", "ekr\."]
|
||||
|
||||
@@ -97,7 +100,7 @@ class DateParserFI(DateParser):
|
||||
# date, whitespace
|
||||
self._span = re.compile("(?P<start>.+)\s+(-)\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile("(vuosien\s*)?(?P<start>.+)\s+ja\s+(?P<stop>.+)\s+väliltä",
|
||||
self._range = re.compile("(vuosien\s*)?(?P<start>.+)\s+ja\s+(?P<stop>.+)\s+välillä",
|
||||
re.IGNORECASE)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@@ -115,6 +118,8 @@ class DateDisplayFI(DateDisplay):
|
||||
u"(Islamilainen)")
|
||||
|
||||
_qual_str = ("", "arviolta", "laskettuna")
|
||||
|
||||
_bce_str = "%s ekr."
|
||||
|
||||
formats = (
|
||||
"VVVV-KK-PP (ISO)",
|
||||
@@ -138,7 +143,7 @@ class DateDisplayFI(DateDisplay):
|
||||
# select numerical date format
|
||||
self.format = 1
|
||||
|
||||
if mod == Date.MOD_SPAN:
|
||||
if mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
text = "%s - %s" % (d1, d2)
|
||||
@@ -147,20 +152,19 @@ class DateDisplayFI(DateDisplay):
|
||||
if start[0] == 0 and start[1] == 0 and stop[0] == 0 and stop[1] == 0:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](stop)
|
||||
text = "vuosien %s ja %s väliltä" % (d1, d2)
|
||||
text = "vuosien %s ja %s välillä" % (d1, d2)
|
||||
else:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](stop)
|
||||
text = "%s ja %s väliltä" % (d1, d2)
|
||||
text = "%s ja %s välillä" % (d1, d2)
|
||||
else:
|
||||
text = self.display_cal[date.get_calendar()](start)
|
||||
if mod == Date.MOD_BEFORE:
|
||||
text = "ennen " + text
|
||||
elif mod == Date.MOD_AFTER:
|
||||
# kludge: should be actually after the date
|
||||
text = "jälkeen " + text
|
||||
if mod == Date.MOD_AFTER:
|
||||
text = text + " jälkeen"
|
||||
elif mod == Date.MOD_ABOUT:
|
||||
text = "noin " + text
|
||||
elif mod == Date.MOD_BEFORE:
|
||||
text = "ennen " + text
|
||||
|
||||
if qual:
|
||||
# prepend quality
|
||||
|
||||
243
src/dates/Date_nl.py
Normal file
243
src/dates/Date_nl.py
Normal file
@@ -0,0 +1,243 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
#
|
||||
# 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; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
# Written by Benny Malengier
|
||||
|
||||
"""
|
||||
Dutch-specific classes for parsing and displaying dates.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import re
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Dutch parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateParserNL(DateParser):
|
||||
|
||||
month_to_int = DateParser.month_to_int
|
||||
# Always add dutch and flemish name variants
|
||||
# no matter what the current locale is
|
||||
month_to_int[u"januari"] = 1
|
||||
month_to_int[u"jan"] = 1
|
||||
# Add other common latin, local and historical variants
|
||||
month_to_int[u"januaris"] = 1
|
||||
month_to_int[u"feber"] = 2
|
||||
month_to_int[u"februaris"] = 2
|
||||
month_to_int[u"merz"] = 2
|
||||
month_to_int[u"aprilis"] = 4
|
||||
month_to_int[u"maius"] = 5
|
||||
month_to_int[u"junius"] = 6
|
||||
month_to_int[u"julius"] = 7
|
||||
month_to_int[u"augst"] = 8
|
||||
month_to_int[u"7ber"] = 9
|
||||
month_to_int[u"7bris"] = 9
|
||||
month_to_int[u"8ber"] = 10
|
||||
month_to_int[u"8bris"] = 10
|
||||
month_to_int[u"9ber"] = 11
|
||||
month_to_int[u"9bris"] = 11
|
||||
month_to_int[u"10ber"] = 12
|
||||
month_to_int[u"10bris"] = 12
|
||||
month_to_int[u"xber"] = 12
|
||||
month_to_int[u"xbris"] = 12
|
||||
|
||||
modifier_to_int = {
|
||||
u'voor' : Date.MOD_BEFORE,
|
||||
u'na' : Date.MOD_AFTER,
|
||||
u'tegen' : Date.MOD_ABOUT,
|
||||
u'om' : Date.MOD_ABOUT,
|
||||
u'rond' : Date.MOD_ABOUT,
|
||||
u'circa' : Date.MOD_ABOUT,
|
||||
u'ca.' : Date.MOD_ABOUT,
|
||||
}
|
||||
|
||||
calendar_to_int = {
|
||||
u'Gregoriaans' : Date.CAL_GREGORIAN,
|
||||
u'Greg.' : Date.CAL_GREGORIAN,
|
||||
u'Juliaans' : Date.CAL_JULIAN,
|
||||
u'Jul.' : Date.CAL_JULIAN,
|
||||
u'Hebreeuws' : Date.CAL_HEBREW,
|
||||
u'Hebr.' : Date.CAL_HEBREW,
|
||||
u'Islamitisch' : Date.CAL_ISLAMIC,
|
||||
u'Isl.' : Date.CAL_ISLAMIC,
|
||||
u'Franse republiek': Date.CAL_FRENCH,
|
||||
u'Fran.' : Date.CAL_FRENCH,
|
||||
u'Persisch' : Date.CAL_PERSIAN,
|
||||
}
|
||||
|
||||
quality_to_int = {
|
||||
u'geschat' : Date.QUAL_ESTIMATED,
|
||||
u'gesch.' : Date.QUAL_ESTIMATED,
|
||||
u'berekend' : Date.QUAL_CALCULATED,
|
||||
u'ber.' : Date.QUAL_CALCULATED,
|
||||
}
|
||||
|
||||
bce = DateParser.bce + ["voor onze tijdrekening",
|
||||
"voor Christus",
|
||||
"v\. Chr\."]
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
self._span = re.compile("(van)\s+(?P<start>.+)\s+(tot)\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile("tussen\s+(?P<start>.+)\s+en\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?'
|
||||
% self._mon_str,
|
||||
re.IGNORECASE)
|
||||
self._jtext2= re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?'
|
||||
% self._jmon_str,
|
||||
re.IGNORECASE)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Dutch display
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayNL(DateDisplay):
|
||||
|
||||
calendar = (
|
||||
"", u" (Juliaans)", u" (Hebreeuws)",
|
||||
u" (Franse Republiek)", u" (Persisch)", u" (Islamitisch)"
|
||||
)
|
||||
|
||||
_mod_str = ("",u"voor ",u"na ",u"rond ","","","")
|
||||
|
||||
_qual_str = ("",u"geschat ",u"berekend ")
|
||||
|
||||
_bce_str = "%s v. Chr."
|
||||
|
||||
formats = (
|
||||
"JJJJ-MM-DD (ISO)", "Numerisch", "Maand Dag Jaar",
|
||||
"MAAND Dag Jaar", "Dag. Maand Jaar", "Dag. MAAND Jaar",
|
||||
"Dag Maand Jaar"
|
||||
)
|
||||
|
||||
def _display_gregorian(self,date_val):
|
||||
year = self._slash_year(date_val[2],date_val[3])
|
||||
if self.format == 0:
|
||||
value = self.display_iso(date_val)
|
||||
elif self.format == 1:
|
||||
if date_val[0] == 0 and date_val[1] == 0:
|
||||
value = str(date_val[2])
|
||||
else:
|
||||
value = self._tformat.replace('%m',str(date_val[1]))
|
||||
value = value.replace('%d',str(date_val[0]))
|
||||
value = value.replace('%Y',str(date_val[2]))
|
||||
elif self.format == 2:
|
||||
# Month Day, Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]],year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._months[date_val[1]],date_val[0],year)
|
||||
elif self.format == 3:
|
||||
# MON Day, Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._MONS[date_val[1]],date_val[0],year)
|
||||
elif self.format == 4:
|
||||
# Day. Month Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]],year)
|
||||
else:
|
||||
value = "%d. %s %s" % (date_val[0],self._months[date_val[1]],year)
|
||||
elif self.format == 5:
|
||||
# Day. MON Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
else:
|
||||
value = "%d. %s %s" % (date_val[0],self._MONS[date_val[1]],year)
|
||||
else:
|
||||
# Day Mon Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._MONS[date_val[1]],year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0],self._MONS[date_val[1]],year)
|
||||
return value
|
||||
|
||||
def display(self,date):
|
||||
"""
|
||||
Returns a text string representing the date.
|
||||
"""
|
||||
mod = date.get_modifier()
|
||||
cal = date.get_calendar()
|
||||
qual = date.get_quality()
|
||||
start = date.get_start_date()
|
||||
|
||||
qual_str = self._qual_str[qual]
|
||||
|
||||
if mod == Date.MOD_TEXTONLY:
|
||||
return date.get_text()
|
||||
elif start == Date.EMPTY:
|
||||
return ""
|
||||
elif mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%s%s %s %s %s%s" % (qual_str,u'van',d1,u'tot',d2,self.calendar[cal])
|
||||
elif mod == Date.MOD_RANGE:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%stussen %s en %s%s" % (qual_str,d1,d2,self.calendar[cal])
|
||||
else:
|
||||
text = self.display_cal[date.get_calendar()](start)
|
||||
return "%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Register classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from DateHandler import register_datehandler
|
||||
register_datehandler(('nl_NL','dutch','nl_BE','nl'),
|
||||
DateParserNL, DateDisplayNL)
|
||||
168
src/dates/Date_sv.py
Normal file
168
src/dates/Date_sv.py
Normal file
@@ -0,0 +1,168 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2005 Donald N. Allingham
|
||||
#
|
||||
# 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; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Swedish-specific classes for parsing and displaying dates.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import re
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Swedish parser class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateParserSv(DateParser):
|
||||
"""
|
||||
Converts a text string into a Date object, expecting a date
|
||||
notation in the swedish language. If the date cannot be converted,
|
||||
the text string is assigned.
|
||||
"""
|
||||
|
||||
# modifiers before the date
|
||||
modifier_to_int = {
|
||||
u'före' : Date.MOD_BEFORE,
|
||||
u'innan' : Date.MOD_BEFORE,
|
||||
u'efter' : Date.MOD_AFTER,
|
||||
u'omkring' : Date.MOD_ABOUT,
|
||||
}
|
||||
|
||||
bce = ["f Kr"]
|
||||
|
||||
calendar_to_int = {
|
||||
u'gregoriansk ' : Date.CAL_GREGORIAN,
|
||||
u'g' : Date.CAL_GREGORIAN,
|
||||
u'juliansk' : Date.CAL_JULIAN,
|
||||
u'j' : Date.CAL_JULIAN,
|
||||
u'hebreisk' : Date.CAL_HEBREW,
|
||||
u'h' : Date.CAL_HEBREW,
|
||||
u'islamisk' : Date.CAL_ISLAMIC,
|
||||
u'muslimsk' : Date.CAL_ISLAMIC,
|
||||
u'i' : Date.CAL_ISLAMIC,
|
||||
u'fransk' : Date.CAL_FRENCH,
|
||||
u'fransk republikansk' : Date.CAL_FRENCH,
|
||||
u'f' : Date.CAL_FRENCH,
|
||||
u'persisk' : Date.CAL_PERSIAN,
|
||||
u'p' : Date.CAL_PERSIAN,
|
||||
}
|
||||
|
||||
quality_to_int = {
|
||||
u'uppskattat' : Date.QUAL_ESTIMATED,
|
||||
u'uppskattad' : Date.QUAL_ESTIMATED,
|
||||
u'bedömt' : Date.QUAL_ESTIMATED,
|
||||
u'bedömd' : Date.QUAL_ESTIMATED,
|
||||
u'beräknat' : Date.QUAL_CALCULATED,
|
||||
u'beräknad' : Date.QUAL_CALCULATED,
|
||||
}
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
self._span = re.compile(u"(från)\s+(?P<start>.+)\s+till\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile(u"(mellan)\s+(?P<start>.+)\s+och\s+(?P<stop>.+)",
|
||||
re.IGNORECASE)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Swedish display class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplaySv(DateDisplay):
|
||||
"""
|
||||
Swedish language date display class.
|
||||
"""
|
||||
|
||||
formats = (
|
||||
u"YYYY-MM-DD (ISO)",
|
||||
u"Numerisk",
|
||||
u"Månad dag, år",
|
||||
u"MÅN DAG ÅR",
|
||||
u"Dag månad år",
|
||||
u"DAG MÅN ÅR",
|
||||
)
|
||||
|
||||
calendar = (
|
||||
"",
|
||||
" (juliansk)",
|
||||
" (hebreisk)",
|
||||
" (fransk republikansk)",
|
||||
" (persisk)",
|
||||
" (islamisk)"
|
||||
)
|
||||
|
||||
_mod_str = ("",u"före ",u"efter ",u"omkring ","","","")
|
||||
|
||||
_qual_str = ("",u"uppskattat ",u"beräknat ")
|
||||
|
||||
_bce_str = "%s f Kr"
|
||||
|
||||
def display(self,date):
|
||||
"""
|
||||
Returns a text string representing the date.
|
||||
"""
|
||||
mod = date.get_modifier()
|
||||
cal = date.get_calendar()
|
||||
qual = date.get_quality()
|
||||
start = date.get_start_date()
|
||||
|
||||
qual_str = self._qual_str[qual]
|
||||
|
||||
if mod == Date.MOD_TEXTONLY:
|
||||
return date.get_text()
|
||||
elif start == Date.EMPTY:
|
||||
return ""
|
||||
elif mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return u"%sfrån %s till %s%s" % (qual_str,d1,d2,self.calendar[cal])
|
||||
elif mod == Date.MOD_RANGE:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return u"%smellan %s och %s%s" % (qual_str,d1,d2,
|
||||
self.calendar[cal])
|
||||
else:
|
||||
text = self.display_cal[date.get_calendar()](start)
|
||||
return "%s%s%s%s" % (qual_str,self._mod_str[mod],
|
||||
text,self.calendar[cal])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Register classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from DateHandler import register_datehandler
|
||||
register_datehandler(('sv_SE','sv','svensk'),DateParserSv, DateDisplaySv)
|
||||
@@ -9,9 +9,10 @@ pkgdata_PYTHON = \
|
||||
Date_de.py\
|
||||
Date_ru.py\
|
||||
Date_fr.py\
|
||||
Date_es.py
|
||||
|
||||
# Date_fi.py
|
||||
Date_es.py\
|
||||
Date_fi.py\
|
||||
Date_sv.py\
|
||||
Date_nl.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/dates
|
||||
pkgpythondir = @pkgpythondir@/dates
|
||||
|
||||
Reference in New Issue
Block a user