* src/DateDisplay.py: Remove localized displayers.
* src/DateParser.py: Remove localized parsers. * src/DateHandler.py: Remove hard-coded localization assignments; load localized classes from dates directory. * src/const.py.in: Add datesDir constant. * src/dates/Date_ru.py: Add to CVS. * src/dates/Date_fr.py: Add to CVS. * src/dates/Makefile.am: Add to CVS. * src/dates/.cvsignore: Add to CVS. * configure.in: Generate src/dates/Makefile. * src/Makefile.am: Add dates to SUBDIRS. svn: r3729
This commit is contained in:
parent
3057994aca
commit
5cf2a52871
@ -1,3 +1,16 @@
|
||||
2004-11-15 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||
* src/DateDisplay.py: Remove localized displayers.
|
||||
* src/DateParser.py: Remove localized parsers.
|
||||
* src/DateHandler.py: Remove hard-coded localization assignments;
|
||||
load localized classes from dates directory.
|
||||
* src/const.py.in: Add datesDir constant.
|
||||
* src/dates/Date_ru.py: Add to CVS.
|
||||
* src/dates/Date_fr.py: Add to CVS.
|
||||
* src/dates/Makefile.am: Add to CVS.
|
||||
* src/dates/.cvsignore: Add to CVS.
|
||||
* configure.in: Generate src/dates/Makefile.
|
||||
* src/Makefile.am: Add dates to SUBDIRS.
|
||||
|
||||
2004-11-14 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/DateParser.py: handle leap year in gregorial validity check
|
||||
* src/MergeData.py: Preserve more data when merging
|
||||
|
@ -245,6 +245,7 @@ src/Makefile
|
||||
src/const.py
|
||||
src/docgen/Makefile
|
||||
src/plugins/Makefile
|
||||
src/dates/Makefile
|
||||
src/data/Makefile
|
||||
src/data/templates/Makefile
|
||||
src/po/Makefile
|
||||
|
@ -295,90 +295,3 @@ class DateDisplay:
|
||||
|
||||
def _display_islamic(self,date_val):
|
||||
return self._display_calendar(date_val,self._islamic)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# French parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayFR(DateDisplay):
|
||||
|
||||
calendar = (
|
||||
"", " (Julien)", " (H\xc3\xa9breu)",
|
||||
" (R\xc3\xa9volutionnaire)", " (Perse)", " (Islamique)"
|
||||
)
|
||||
|
||||
_mod_str = ("","avant ","apr\xc3\xa8s ","vers ","","","")
|
||||
|
||||
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 "%sde %s \xc3\xa0 %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 "%sentre %s et %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])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Russian parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayRU(DateDisplay):
|
||||
|
||||
calendar = (
|
||||
"", " (\xd1\x8e\xd0\xbb\xd0\xb8\xd0\xb0\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9)",
|
||||
" (\xd0\xb5\xd0\xb2\xd1\x80\xd0\xb5\xd0\xb9\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9)",
|
||||
" (\xd1\x80\xd0\xb5\xd1\x81\xd0\xbf\xd1\x83\xd0\xb1\xd0\xbb\xd0\xb8\xd0\xba\xd0\xb0\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9)",
|
||||
" (\xd0\xbf\xd0\xb5\xd1\x80\xd1\x81\xd0\xb8\xd0\xb4\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9)",
|
||||
" (\xd0\xb8\xd1\x81\xd0\xbb\xd0\xb0\xd0\xbc\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9)"
|
||||
)
|
||||
|
||||
_mod_str = ("","\xd0\xb4\xd0\xbe ",
|
||||
"\xd0\xbf\xd0\xbe\xd1\x81\xd0\xbb\xd0\xb5 ",
|
||||
"\xd0\xbe\xd0\xba\xd0\xbe\xd0\xbb\xd0\xbe ","","","")
|
||||
|
||||
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\xd1\x81 %s \xd0\xbf\xd0\xbe %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 "%s\xd0\xbc\xd0\xb5\xd0\xb6\xd0\xb4\xd1\x83 %s \xd0\xb8 %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])
|
||||
|
@ -50,32 +50,22 @@ _lang = locale.getlocale(locale.LC_TIME)[0]
|
||||
|
||||
_lang_to_parser = {
|
||||
'C' : DateParser.DateParser,
|
||||
'fr_FR' : DateParser.DateParserFR,
|
||||
'en_US' : DateParser.DateParser,
|
||||
'en_GB' : DateParser.DateParser,
|
||||
'en_AU' : DateParser.DateParser,
|
||||
'en_CA' : DateParser.DateParser,
|
||||
'en_SE' : DateParser.DateParser,
|
||||
'en' : DateParser.DateParser,
|
||||
'ru_RU' : DateParser.DateParserRU,
|
||||
'ru_RU.koi8r' : DateParser.DateParserRU,
|
||||
'ru_RU.utf8' : DateParser.DateParserRU,
|
||||
'russian' : DateParser.DateParserRU,
|
||||
}
|
||||
|
||||
_lang_to_display = {
|
||||
'C' : DateDisplay.DateDisplay,
|
||||
'fr_FR' : DateDisplay.DateDisplayFR,
|
||||
'en_US' : DateDisplay.DateDisplay,
|
||||
'en_GB' : DateDisplay.DateDisplay,
|
||||
'en_AU' : DateDisplay.DateDisplay,
|
||||
'en_CA' : DateDisplay.DateDisplay,
|
||||
'en_SE' : DateDisplay.DateDisplay,
|
||||
'en' : DateDisplay.DateDisplay,
|
||||
'ru_RU' : DateDisplay.DateDisplayRU,
|
||||
'ru_RU.koi8r' : DateDisplay.DateDisplayRU,
|
||||
'ru_RU.utf8' : DateDisplay.DateDisplayRU,
|
||||
'russian' : DateDisplay.DateDisplayRU,
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -116,3 +106,12 @@ def get_format():
|
||||
except:
|
||||
print "not found"
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Import localized date classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Plugins import load_plugins
|
||||
from const import datesDir
|
||||
load_plugins(datesDir)
|
||||
|
@ -524,117 +524,3 @@ class DateParser:
|
||||
new_date = Date.Date()
|
||||
self.set_date(new_date,text)
|
||||
return new_date
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# French parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateParserFR(DateParser):
|
||||
|
||||
modifier_to_int = {
|
||||
'avant' : Date.MOD_BEFORE,
|
||||
'av.' : Date.MOD_BEFORE,
|
||||
'av' : Date.MOD_BEFORE,
|
||||
'apr\xc3\xa8s' : Date.MOD_AFTER,
|
||||
'ap.' : Date.MOD_AFTER,
|
||||
'ap' : Date.MOD_AFTER,
|
||||
'env.' : Date.MOD_ABOUT,
|
||||
'env' : Date.MOD_ABOUT,
|
||||
'circa' : Date.MOD_ABOUT,
|
||||
'c.' : Date.MOD_ABOUT,
|
||||
'vers' : Date.MOD_ABOUT,
|
||||
}
|
||||
|
||||
calendar_to_int = {
|
||||
'gr\xc3\xa9gorien' : Date.CAL_GREGORIAN,
|
||||
'g' : Date.CAL_GREGORIAN,
|
||||
'julien' : Date.CAL_JULIAN,
|
||||
'j' : Date.CAL_JULIAN,
|
||||
'h\xc3\xa9breu' : Date.CAL_HEBREW,
|
||||
'h' : Date.CAL_HEBREW,
|
||||
'islamique' : Date.CAL_ISLAMIC,
|
||||
'i' : Date.CAL_ISLAMIC,
|
||||
'r\xc3\xa9volutionnaire': Date.CAL_FRENCH,
|
||||
'r' : Date.CAL_FRENCH,
|
||||
'perse' : Date.CAL_PERSIAN,
|
||||
'p' : Date.CAL_PERSIAN,
|
||||
}
|
||||
|
||||
quality_to_int = {
|
||||
'estimated' : Date.QUAL_ESTIMATED,
|
||||
'est.' : Date.QUAL_ESTIMATED,
|
||||
'est' : Date.QUAL_ESTIMATED,
|
||||
'calc.' : Date.QUAL_CALCULATED,
|
||||
'calc' : Date.QUAL_CALCULATED,
|
||||
'calculated' : Date.QUAL_CALCULATED,
|
||||
}
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
self._span = re.compile("(de)\s+(.+)\s+(\xc3\xa0)\s+(.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile("(ent.|ent|entre)\s+(.+)\s+(et)\s+(.+)",
|
||||
re.IGNORECASE)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Russian parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateParserRU(DateParser):
|
||||
|
||||
modifier_to_int = {
|
||||
'\xd0\xb4\xd0\xbe' : Date.MOD_BEFORE,
|
||||
'\xd0\xbf\xd0\xbe' : Date.MOD_BEFORE,
|
||||
'\xd0\xbf\xd0\xbe\xd1\x81\xd0\xbb\xd0\xb5' : Date.MOD_AFTER,
|
||||
'\xd0\xbf.' : Date.MOD_AFTER,
|
||||
'\xd0\xbf' : Date.MOD_AFTER,
|
||||
'\xd1\x81' : Date.MOD_AFTER,
|
||||
'\xd0\xbe\xd0\xba' : Date.MOD_ABOUT,
|
||||
'\xd0\xbe\xd0\xba.' : Date.MOD_ABOUT,
|
||||
'\xd0\xbe\xd0\xba\xd0\xbe\xd0\xbb\xd0\xbe' : Date.MOD_ABOUT,
|
||||
'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xbc\xd0\xb5\xd1\x80\xd0\xbd\xd0\xbe' : Date.MOD_ABOUT,
|
||||
'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xbc' : Date.MOD_ABOUT,
|
||||
'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xbc.' : Date.MOD_ABOUT,
|
||||
'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb1\xd0\xbb\xd0\xb8\xd0\xb7\xd0\xb8\xd1\x82\xd0\xb5\xd0\xbb\xd1\x8c\xd0\xbd\xd0\xbe' : Date.MOD_ABOUT,
|
||||
'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb1.' : Date.MOD_ABOUT,
|
||||
'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb1\xd0\xbb.' : Date.MOD_ABOUT,
|
||||
'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb1' : Date.MOD_ABOUT,
|
||||
'\xd0\xbf\xd1\x80\xd0\xb8\xd0\xb1\xd0\xbb' : Date.MOD_ABOUT,
|
||||
}
|
||||
|
||||
calendar_to_int = {
|
||||
'\xd0\xb3\xd1\x80\xd0\xb8\xd0\xb3\xd0\xbe\xd1\x80\xd0\xb8\xd0\xb0\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9' : Date.CAL_GREGORIAN,
|
||||
'\xd0\xb3' : Date.CAL_GREGORIAN,
|
||||
'\xd1\x8e\xd0\xbb\xd0\xb8\xd0\xb0\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9' : Date.CAL_JULIAN,
|
||||
'\xd1\x8e' : Date.CAL_JULIAN,
|
||||
'\xd0\xb5\xd0\xb2\xd1\x80\xd0\xb5\xd0\xb9\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9' : Date.CAL_HEBREW,
|
||||
'\xd0\xb5' : Date.CAL_HEBREW,
|
||||
'\xd0\xb8\xd1\x81\xd0\xbb\xd0\xb0\xd0\xbc\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9' : Date.CAL_ISLAMIC,
|
||||
'\xd0\xb8' : Date.CAL_ISLAMIC,
|
||||
'\xd1\x80\xd0\xb5\xd1\x81\xd0\xbf\xd1\x83\xd0\xb1\xd0\xbb\xd0\xb8\xd0\xba\xd0\xb0\xd0\xbd\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9': Date.CAL_FRENCH,
|
||||
'\xd1\x80' : Date.CAL_FRENCH,
|
||||
'\xd0\xbf\xd0\xb5\xd1\x80\xd1\x81\xd0\xb8\xd0\xb4\xd1\x81\xd0\xba\xd0\xb8\xd0\xb9' : Date.CAL_PERSIAN,
|
||||
'\xd0\xbf' : Date.CAL_PERSIAN,
|
||||
}
|
||||
|
||||
quality_to_int = {
|
||||
'\xd0\xbe\xd1\x86\xd0\xb5\xd0\xbd\xd0\xb5\xd0\xbd\xd0\xbe' : Date.QUAL_ESTIMATED,
|
||||
'\xd0\xbe\xd1\x86\xd0\xb5\xd0\xbd.' : Date.QUAL_ESTIMATED,
|
||||
'\xd0\xbe\xd1\x86.' : Date.QUAL_ESTIMATED,
|
||||
'\xd0\xbe\xd1\x86\xd0\xb5\xd0\xbd' : Date.QUAL_ESTIMATED,
|
||||
'\xd0\xbe\xd1\x86' : Date.QUAL_ESTIMATED,
|
||||
'\xd0\xb2\xd1\x8b\xd1\x87\xd0\xb8\xd1\x81\xd0\xbb\xd0\xb5\xd0\xbd\xd0\xbe' : Date.QUAL_CALCULATED,
|
||||
'\xd0\xb2\xd1\x8b\xd1\x87\xd0\xb8\xd1\x81\xd0\xbb.' : Date.QUAL_CALCULATED,
|
||||
'\xd0\xb2\xd1\x8b\xd1\x87.' : Date.QUAL_CALCULATED,
|
||||
'\xd0\xb2\xd1\x8b\xd1\x87\xd0\xb8\xd1\x81\xd0\xbb' : Date.QUAL_CALCULATED,
|
||||
'\xd0\xb2\xd1\x8b\xd1\x87' : Date.QUAL_CALCULATED,
|
||||
}
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
self._span = re.compile("(\xd1\x81|\xd0\xbe\xd1\x82)\\s+(.+)\\s+(\xd0\xbf\xd0\xbe|\xd0\xb4\xd0\xbe)\\s+(.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile("(\xd0\xbc\xd0\xb5\xd0\xb6\xd0\xb4\xd1\x83|\xd0\xbc\xd0\xb5\xd0\xb6|\xd0\xbc\xd0\xb5\xd0\xb6.)\\s+(.+)\\s+(\xd0\xb8)\\s+(.+)",
|
||||
re.IGNORECASE)
|
||||
|
@ -1,5 +1,5 @@
|
||||
# This is the src level Makefile for Gramps
|
||||
SUBDIRS = docgen plugins data po
|
||||
SUBDIRS = docgen plugins dates data po
|
||||
|
||||
# For intl. support, how do we compile?
|
||||
MOSTLYCLEANFILES =
|
||||
|
@ -96,6 +96,7 @@ filterFile = "%s/rule.glade" % rootDir
|
||||
errdialogsFile = "%s/gramps.glade" % rootDir
|
||||
|
||||
pluginsDir = "%s/plugins" % rootDir
|
||||
datesDir = "%s/dates" % rootDir
|
||||
docgenDir = "%s/docgen" % rootDir
|
||||
dataDir = "%s/data" % rootDir
|
||||
template_dir = "%s/templates" % dataDir
|
||||
|
4
gramps2/src/dates/.cvsignore
Normal file
4
gramps2/src/dates/.cvsignore
Normal file
@ -0,0 +1,4 @@
|
||||
Makefile
|
||||
Makefile.in
|
||||
*.pyc
|
||||
*.pyo
|
146
gramps2/src/dates/Date_fr.py
Normal file
146
gramps2/src/dates/Date_fr.py
Normal file
@ -0,0 +1,146 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004 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$
|
||||
|
||||
"""
|
||||
French-specific classes for parsing and displaying dates.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import re
|
||||
import calendar
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# French parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateParserFR(DateParser):
|
||||
|
||||
modifier_to_int = {
|
||||
'avant' : Date.MOD_BEFORE,
|
||||
'av.' : Date.MOD_BEFORE,
|
||||
'av' : Date.MOD_BEFORE,
|
||||
'après' : Date.MOD_AFTER,
|
||||
'ap.' : Date.MOD_AFTER,
|
||||
'ap' : Date.MOD_AFTER,
|
||||
'env.' : Date.MOD_ABOUT,
|
||||
'env' : Date.MOD_ABOUT,
|
||||
'circa' : Date.MOD_ABOUT,
|
||||
'c.' : Date.MOD_ABOUT,
|
||||
'vers' : Date.MOD_ABOUT,
|
||||
}
|
||||
|
||||
calendar_to_int = {
|
||||
'grégorien' : Date.CAL_GREGORIAN,
|
||||
'g' : Date.CAL_GREGORIAN,
|
||||
'julien' : Date.CAL_JULIAN,
|
||||
'j' : Date.CAL_JULIAN,
|
||||
'hébreu' : Date.CAL_HEBREW,
|
||||
'h' : Date.CAL_HEBREW,
|
||||
'islamique' : Date.CAL_ISLAMIC,
|
||||
'i' : Date.CAL_ISLAMIC,
|
||||
'révolutionnaire': Date.CAL_FRENCH,
|
||||
'r' : Date.CAL_FRENCH,
|
||||
'perse' : Date.CAL_PERSIAN,
|
||||
'p' : Date.CAL_PERSIAN,
|
||||
}
|
||||
|
||||
quality_to_int = {
|
||||
'estimated' : Date.QUAL_ESTIMATED,
|
||||
'est.' : Date.QUAL_ESTIMATED,
|
||||
'est' : Date.QUAL_ESTIMATED,
|
||||
'calc.' : Date.QUAL_CALCULATED,
|
||||
'calc' : Date.QUAL_CALCULATED,
|
||||
'calculated' : Date.QUAL_CALCULATED,
|
||||
}
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
self._span = re.compile("(de)\s+(.+)\s+(à)\s+(.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile("(ent.|ent|entre)\s+(.+)\s+(et)\s+(.+)",
|
||||
re.IGNORECASE)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# French display
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayFR(DateDisplay):
|
||||
|
||||
calendar = (
|
||||
"", " (Julien)", " (Hébreu)",
|
||||
" (Révolutionnaire)", " (Perse)", " (Islamique)"
|
||||
)
|
||||
|
||||
_mod_str = ("","avant ","après ","vers ","","","")
|
||||
|
||||
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 "%sde %s à %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 "%sentre %s et %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 _lang_to_parser, _lang_to_display
|
||||
for lang_str in ('fr_FR','fr_FR.iso88591','fr_FR.utf8','french'):
|
||||
_lang_to_parser[lang_str] = DateParserFR
|
||||
_lang_to_display[lang_str] = DateDisplayFR
|
161
gramps2/src/dates/Date_ru.py
Normal file
161
gramps2/src/dates/Date_ru.py
Normal file
@ -0,0 +1,161 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004 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$
|
||||
|
||||
"""
|
||||
Russian-specific classes for parsing and displaying dates.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import re
|
||||
import calendar
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Date
|
||||
from DateParser import DateParser
|
||||
from DateDisplay import DateDisplay
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Russian parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateParserRU(DateParser):
|
||||
|
||||
modifier_to_int = {
|
||||
'до' : Date.MOD_BEFORE,
|
||||
'по' : Date.MOD_BEFORE,
|
||||
'после' : Date.MOD_AFTER,
|
||||
'п.' : Date.MOD_AFTER,
|
||||
'п' : Date.MOD_AFTER,
|
||||
'с' : Date.MOD_AFTER,
|
||||
'ок' : Date.MOD_ABOUT,
|
||||
'ок.' : Date.MOD_ABOUT,
|
||||
'около' : Date.MOD_ABOUT,
|
||||
'примерно' : Date.MOD_ABOUT,
|
||||
'прим' : Date.MOD_ABOUT,
|
||||
'прим.' : Date.MOD_ABOUT,
|
||||
'приблизительно' : Date.MOD_ABOUT,
|
||||
'приб.' : Date.MOD_ABOUT,
|
||||
'прибл.' : Date.MOD_ABOUT,
|
||||
'приб' : Date.MOD_ABOUT,
|
||||
'прибл' : Date.MOD_ABOUT,
|
||||
}
|
||||
|
||||
calendar_to_int = {
|
||||
'григорианский' : Date.CAL_GREGORIAN,
|
||||
'г' : Date.CAL_GREGORIAN,
|
||||
'юлианский' : Date.CAL_JULIAN,
|
||||
'ю' : Date.CAL_JULIAN,
|
||||
'еврейский' : Date.CAL_HEBREW,
|
||||
'е' : Date.CAL_HEBREW,
|
||||
'исламский' : Date.CAL_ISLAMIC,
|
||||
'и' : Date.CAL_ISLAMIC,
|
||||
'республиканский': Date.CAL_FRENCH,
|
||||
'р' : Date.CAL_FRENCH,
|
||||
'персидский' : Date.CAL_PERSIAN,
|
||||
'п' : Date.CAL_PERSIAN,
|
||||
}
|
||||
|
||||
quality_to_int = {
|
||||
'оценено' : Date.QUAL_ESTIMATED,
|
||||
'оцен.' : Date.QUAL_ESTIMATED,
|
||||
'оц.' : Date.QUAL_ESTIMATED,
|
||||
'оцен' : Date.QUAL_ESTIMATED,
|
||||
'оц' : Date.QUAL_ESTIMATED,
|
||||
'вычислено' : Date.QUAL_CALCULATED,
|
||||
'вычисл.' : Date.QUAL_CALCULATED,
|
||||
'выч.' : Date.QUAL_CALCULATED,
|
||||
'вычисл' : Date.QUAL_CALCULATED,
|
||||
'выч' : Date.QUAL_CALCULATED,
|
||||
}
|
||||
|
||||
def init_strings(self):
|
||||
DateParser.init_strings(self)
|
||||
self._span = re.compile("(с|от)\s+(.+)\s+(по|до)\s+(.+)",
|
||||
re.IGNORECASE)
|
||||
self._range = re.compile("(между|меж|меж.)\s+(.+)\s+(и)\s+(.+)",
|
||||
re.IGNORECASE)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Russian displayer
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayRU(DateDisplay):
|
||||
|
||||
calendar = (
|
||||
"", " (юлианский)",
|
||||
" (еврейский)",
|
||||
" (республиканский)",
|
||||
" (персидский)",
|
||||
" (исламский)"
|
||||
)
|
||||
|
||||
_mod_str = ("","до ",
|
||||
"после ",
|
||||
"около ","","","")
|
||||
|
||||
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" % (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 "%sмежду %s и %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 _lang_to_parser, _lang_to_display
|
||||
for lang_str in ('ru_RU','ru_RU.koi8r','ru_RU.utf8','russian'):
|
||||
_lang_to_parser[lang_str] = DateParserRU
|
||||
_lang_to_display[lang_str] = DateDisplayRU
|
19
gramps2/src/dates/Makefile.am
Normal file
19
gramps2/src/dates/Makefile.am
Normal file
@ -0,0 +1,19 @@
|
||||
# This is the src/plugins level Makefile for Gramps
|
||||
# We could use GNU make's ':=' syntax for nice wildcard use,
|
||||
# but that is not necessarily portable.
|
||||
# If not using GNU make, then list all .py files individually
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/dates
|
||||
|
||||
pkgdata_PYTHON = \
|
||||
Date_ru.py\
|
||||
Date_fr.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/dates
|
||||
pkgpythondir = @pkgpythondir@/dates
|
||||
|
||||
GRAMPS_PY_MODPATH = ".."
|
||||
|
||||
pycheck:
|
||||
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
|
||||
pychecker $(pkgdata_PYTHON));
|
Loading…
Reference in New Issue
Block a user