* src/DateHandler.py: add handlers for fr_FR
* src/DateParser.py: add parser for french * src/DateDisplay.py: add displayer for french * src/gramps.py: Better way of setting locale * src/DateHandler.py: Better locate settings svn: r3714
This commit is contained in:
parent
6c682adc40
commit
8ea34283c8
@ -1,3 +1,12 @@
|
|||||||
|
2004-11-08 Don Allingham <dallingham@users.sourceforge.net>
|
||||||
|
* src/DateHandler.py: add handlers for fr_FR
|
||||||
|
* src/DateParser.py: add parser for french
|
||||||
|
* src/DateDisplay.py: add displayer for french
|
||||||
|
|
||||||
|
2004-11-08 Steve Swales <Steve.Swales@sun.com>
|
||||||
|
* src/gramps.py: Better way of setting locale
|
||||||
|
* src/DateHandler.py: Better locate settings
|
||||||
|
|
||||||
2004-11-08 Alex Roitman <shura@alex.neuro.umn.edu>
|
2004-11-08 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
* src/data/Makefile.am: Remove gramps.desktop from
|
* src/data/Makefile.am: Remove gramps.desktop from
|
||||||
dist_pkgdata_DATA which was causing it to get installed
|
dist_pkgdata_DATA which was causing it to get installed
|
||||||
|
@ -296,3 +296,39 @@ class DateDisplay:
|
|||||||
def _display_islamic(self,date_val):
|
def _display_islamic(self,date_val):
|
||||||
return self._display_calendar(date_val,self._islamic)
|
return self._display_calendar(date_val,self._islamic)
|
||||||
|
|
||||||
|
class DateDisplayFR(DateDisplay):
|
||||||
|
|
||||||
|
calendar = (
|
||||||
|
u"", u" (Julien)", u" (H\xe9breu)",
|
||||||
|
u" (R\xe9volutionnaire)", u" (Perse)", u" (Islamique)"
|
||||||
|
)
|
||||||
|
|
||||||
|
_mod_str = (u"",u"avant ",u"apr\xe8s ",u"vers ",u"",u"",u"")
|
||||||
|
|
||||||
|
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 u""
|
||||||
|
elif mod == Date.MOD_SPAN:
|
||||||
|
d1 = self.display_cal[cal](start)
|
||||||
|
d2 = self.display_cal[cal](date.get_stop_date())
|
||||||
|
return u"%sde %s \xe0 %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"%sentre %s et %s%s" % (qual_str,d1,d2,self.calendar[cal])
|
||||||
|
else:
|
||||||
|
text = self.display_cal[date.get_calendar()](start)
|
||||||
|
return u"%s%s%s%s" % (qual_str,self._mod_str[mod],text,self.calendar[cal])
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ Class handling language-specific selection for date parser and displayer.
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import os
|
import os
|
||||||
|
import locale
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -45,11 +46,11 @@ import DateDisplay
|
|||||||
# Constants
|
# Constants
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
_lang = os.environ.get('LANG','C').split('.')[0]
|
_lang = locale.getlocale(locale.LC_TIME)[0]
|
||||||
|
|
||||||
|
|
||||||
_lang_to_parser = {
|
_lang_to_parser = {
|
||||||
'C' : DateParser.DateParser,
|
'C' : DateParser.DateParser,
|
||||||
|
'fr_FR' : DateParser.DateParserFR,
|
||||||
'en_US' : DateParser.DateParser,
|
'en_US' : DateParser.DateParser,
|
||||||
'en_GB' : DateParser.DateParser,
|
'en_GB' : DateParser.DateParser,
|
||||||
'en_AU' : DateParser.DateParser,
|
'en_AU' : DateParser.DateParser,
|
||||||
@ -60,6 +61,7 @@ _lang_to_parser = {
|
|||||||
|
|
||||||
_lang_to_display = {
|
_lang_to_display = {
|
||||||
'C' : DateDisplay.DateDisplay,
|
'C' : DateDisplay.DateDisplay,
|
||||||
|
'fr_FR' : DateDisplay.DateDisplayFR,
|
||||||
'en_US' : DateDisplay.DateDisplay,
|
'en_US' : DateDisplay.DateDisplay,
|
||||||
'en_GB' : DateDisplay.DateDisplay,
|
'en_GB' : DateDisplay.DateDisplay,
|
||||||
'en_AU' : DateDisplay.DateDisplay,
|
'en_AU' : DateDisplay.DateDisplay,
|
||||||
|
@ -486,6 +486,53 @@ class DateParser:
|
|||||||
self.set_date(new_date,text)
|
self.set_date(new_date,text)
|
||||||
return new_date
|
return new_date
|
||||||
|
|
||||||
|
class DateParserFR(DateParser):
|
||||||
|
|
||||||
|
modifier_to_int = {
|
||||||
|
u'avant' : Date.MOD_BEFORE,
|
||||||
|
u'av.' : Date.MOD_BEFORE,
|
||||||
|
u'av' : Date.MOD_BEFORE,
|
||||||
|
u'apr\xe8s' : 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,
|
||||||
|
}
|
||||||
|
|
||||||
|
calendar_to_int = {
|
||||||
|
u'gr\xe9gorien' : Date.CAL_GREGORIAN,
|
||||||
|
u'g' : Date.CAL_GREGORIAN,
|
||||||
|
u'julien' : Date.CAL_JULIAN,
|
||||||
|
u'j' : Date.CAL_JULIAN,
|
||||||
|
u'h\xe9breu' : Date.CAL_HEBREW,
|
||||||
|
u'h' : Date.CAL_HEBREW,
|
||||||
|
u'islamique' : Date.CAL_ISLAMIC,
|
||||||
|
u'i' : Date.CAL_ISLAMIC,
|
||||||
|
u'r\xe9volutionnaire': Date.CAL_FRENCH,
|
||||||
|
u'r' : Date.CAL_FRENCH,
|
||||||
|
u'perse' : Date.CAL_PERSIAN,
|
||||||
|
u'p' : Date.CAL_PERSIAN,
|
||||||
|
}
|
||||||
|
|
||||||
|
quality_to_int = {
|
||||||
|
u'estimated' : Date.QUAL_ESTIMATED,
|
||||||
|
u'est.' : Date.QUAL_ESTIMATED,
|
||||||
|
u'est' : Date.QUAL_ESTIMATED,
|
||||||
|
u'calc.' : Date.QUAL_CALCULATED,
|
||||||
|
u'calc' : Date.QUAL_CALCULATED,
|
||||||
|
u'calculated' : Date.QUAL_CALCULATED,
|
||||||
|
}
|
||||||
|
|
||||||
|
_span = re.compile("de\s+(.+)\s+\xe0\s+(.+)",
|
||||||
|
re.IGNORECASE)
|
||||||
|
_range = re.compile("(ent.|ent|entre)\s+(.+)\s+et\s+(.+)",
|
||||||
|
re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_max_days = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
|
_max_days = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ]
|
||||||
|
|
||||||
def gregorian_valid(date_tuple):
|
def gregorian_valid(date_tuple):
|
||||||
@ -497,3 +544,4 @@ def gregorian_valid(date_tuple):
|
|||||||
elif day > _max_days[month]:
|
elif day > _max_days[month]:
|
||||||
valid = False
|
valid = False
|
||||||
return valid
|
return valid
|
||||||
|
|
||||||
|
@ -55,8 +55,8 @@ else:
|
|||||||
loc = "/usr/share/locale"
|
loc = "/usr/share/locale"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
locale.setlocale(locale.LC_ALL,'C')
|
||||||
locale.setlocale(locale.LC_ALL,'')
|
locale.setlocale(locale.LC_ALL,'')
|
||||||
locale.setlocale(locale.LC_TIME,os.environ.get('LANG','C'))
|
|
||||||
except locale.Error:
|
except locale.Error:
|
||||||
pass
|
pass
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
Loading…
Reference in New Issue
Block a user