2004-11-16 09:14:23 +05:30
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2005-01-19 10:43:09 +05:30
|
|
|
# Copyright (C) 2004-2005 Donald N. Allingham
|
2004-11-16 09:14:23 +05:30
|
|
|
#
|
|
|
|
# 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$
|
|
|
|
|
|
|
|
"""
|
|
|
|
French-specific classes for parsing and displaying dates.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import re
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import Date
|
|
|
|
from DateParser import DateParser
|
|
|
|
from DateDisplay import DateDisplay
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# French parser
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DateParserFR(DateParser):
|
|
|
|
|
|
|
|
modifier_to_int = {
|
2004-11-17 09:06:18 +05:30
|
|
|
u'avant' : Date.MOD_BEFORE,
|
|
|
|
u'av.' : Date.MOD_BEFORE,
|
|
|
|
u'av' : Date.MOD_BEFORE,
|
|
|
|
u'après' : Date.MOD_AFTER,
|
|
|
|
u'ap.' : Date.MOD_AFTER,
|
|
|
|
u'ap' : Date.MOD_AFTER,
|
|
|
|
u'env.' : Date.MOD_ABOUT,
|
|
|
|
u'env' : Date.MOD_ABOUT,
|
|
|
|
u'circa' : Date.MOD_ABOUT,
|
|
|
|
u'c.' : Date.MOD_ABOUT,
|
|
|
|
u'vers' : Date.MOD_ABOUT,
|
2004-11-16 09:14:23 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
calendar_to_int = {
|
2004-11-17 09:06:18 +05:30
|
|
|
u'grégorien' : Date.CAL_GREGORIAN,
|
|
|
|
u'g' : Date.CAL_GREGORIAN,
|
|
|
|
u'julien' : Date.CAL_JULIAN,
|
|
|
|
u'j' : Date.CAL_JULIAN,
|
|
|
|
u'hébreu' : Date.CAL_HEBREW,
|
|
|
|
u'h' : Date.CAL_HEBREW,
|
|
|
|
u'islamique' : Date.CAL_ISLAMIC,
|
|
|
|
u'i' : Date.CAL_ISLAMIC,
|
|
|
|
u'révolutionnaire': Date.CAL_FRENCH,
|
|
|
|
u'r' : Date.CAL_FRENCH,
|
|
|
|
u'perse' : Date.CAL_PERSIAN,
|
|
|
|
u'p' : Date.CAL_PERSIAN,
|
2004-11-16 09:14:23 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
quality_to_int = {
|
2004-11-17 09:06:18 +05:30
|
|
|
u'estimated' : Date.QUAL_ESTIMATED,
|
2005-12-13 07:37:16 +05:30
|
|
|
u'estimer' : Date.QUAL_ESTIMATED,
|
2004-11-17 09:06:18 +05:30
|
|
|
u'est.' : Date.QUAL_ESTIMATED,
|
|
|
|
u'est' : Date.QUAL_ESTIMATED,
|
2005-12-13 07:37:16 +05:30
|
|
|
u'environ' : Date.QUAL_ESTIMATED,
|
|
|
|
u'env' : Date.QUAL_ESTIMATED,
|
|
|
|
u'env.' : Date.QUAL_ESTIMATED,
|
|
|
|
u'calculer' : Date.QUAL_CALCULATED,
|
2004-11-17 09:06:18 +05:30
|
|
|
u'calc.' : Date.QUAL_CALCULATED,
|
|
|
|
u'calc' : Date.QUAL_CALCULATED,
|
2005-12-13 07:37:16 +05:30
|
|
|
u'compter' : Date.QUAL_CALCULATED,
|
|
|
|
u'compt' : Date.QUAL_CALCULATED,
|
|
|
|
u'compt.' : Date.QUAL_CALCULATED,
|
2004-11-17 09:06:18 +05:30
|
|
|
u'calculated' : Date.QUAL_CALCULATED,
|
2004-11-16 09:14:23 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
def init_strings(self):
|
|
|
|
DateParser.init_strings(self)
|
2004-11-17 09:06:18 +05:30
|
|
|
_span_1 = [u'de']
|
|
|
|
_span_2 = [u'à']
|
|
|
|
_range_1 = [u'ent.',u'ent',u'entre']
|
|
|
|
_range_2 = [u'et']
|
2005-06-05 09:31:56 +05:30
|
|
|
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
2004-11-17 09:06:18 +05:30
|
|
|
('|'.join(_span_1),'|'.join(_span_2)),
|
2004-11-16 09:14:23 +05:30
|
|
|
re.IGNORECASE)
|
2005-06-05 09:31:56 +05:30
|
|
|
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
2004-11-17 09:06:18 +05:30
|
|
|
('|'.join(_range_1),'|'.join(_range_2)),
|
2004-11-16 09:14:23 +05:30
|
|
|
re.IGNORECASE)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# French display
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class DateDisplayFR(DateDisplay):
|
|
|
|
|
|
|
|
calendar = (
|
2004-11-17 09:06:18 +05:30
|
|
|
"", u" (Julien)", u" (Hébreu)",
|
|
|
|
u" (Révolutionnaire)", u" (Perse)", u" (Islamique)"
|
2004-11-16 09:14:23 +05:30
|
|
|
)
|
|
|
|
|
2004-11-17 09:06:18 +05:30
|
|
|
_mod_str = ("",u"avant ",u"après ",u"vers ","","","")
|
2004-11-16 09:14:23 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
_qual_str = ("","estimated ","calculated ")
|
2005-01-19 10:43:09 +05:30
|
|
|
|
|
|
|
formats = (
|
2005-01-28 11:32:33 +05:30
|
|
|
"AAAA-MM-DD (ISO)", "Numérique", "Mois Jour, Année",
|
2005-01-19 10:43:09 +05:30
|
|
|
"MOI Jour, Année", "Jour Mois, Année", "Jour MOIS Année"
|
|
|
|
)
|
|
|
|
|
2004-11-16 09:14:23 +05:30
|
|
|
def display(self,date):
|
|
|
|
"""
|
2005-01-19 10:45:30 +05:30
|
|
|
Returns a text string representing the date.
|
|
|
|
"""
|
2004-11-16 09:14:23 +05:30
|
|
|
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())
|
2004-11-17 09:06:18 +05:30
|
|
|
return "%s%s %s %s %s%s" % (qual_str,u'de',d1,u'à',d2,self.calendar[cal])
|
2004-11-16 09:14:23 +05:30
|
|
|
elif mod == Date.MOD_RANGE:
|
|
|
|
d1 = self.display_cal[cal](start)
|
|
|
|
d2 = self.display_cal[cal](date.get_stop_date())
|
2004-11-17 09:06:18 +05:30
|
|
|
return "%s%s %s %s %s%s" % (qual_str,u'entre',d1,u'et',d2,self.calendar[cal])
|
2004-11-16 09:14:23 +05:30
|
|
|
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
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-12-26 23:53:50 +05:30
|
|
|
from DateHandler import register_datehandler
|
2005-06-05 09:31:56 +05:30
|
|
|
register_datehandler(('fr_FR','fr','french'),DateParserFR, DateDisplayFR)
|