polish date handler for french locales
This commit is contained in:
parent
20ca667b61
commit
c2ee4b0ab9
@ -77,7 +77,7 @@ class DateParserFR(DateParser):
|
|||||||
'vers' : Date.MOD_ABOUT,
|
'vers' : Date.MOD_ABOUT,
|
||||||
'~' : Date.MOD_ABOUT,
|
'~' : Date.MOD_ABOUT,
|
||||||
}
|
}
|
||||||
|
|
||||||
quality_to_int = {
|
quality_to_int = {
|
||||||
'estimée': Date.QUAL_ESTIMATED,
|
'estimée': Date.QUAL_ESTIMATED,
|
||||||
'est.' : Date.QUAL_ESTIMATED,
|
'est.' : Date.QUAL_ESTIMATED,
|
||||||
@ -96,7 +96,7 @@ class DateParserFR(DateParser):
|
|||||||
def init_strings(self):
|
def init_strings(self):
|
||||||
"""
|
"""
|
||||||
This method compiles regular expression strings for matching dates.
|
This method compiles regular expression strings for matching dates.
|
||||||
|
|
||||||
Most of the re's in most languages can stay as is. span and range
|
Most of the re's in most languages can stay as is. span and range
|
||||||
most likely will need to change. Whatever change is done, this method
|
most likely will need to change. Whatever change is done, this method
|
||||||
may be called first as DateParser.init_strings(self) so that the
|
may be called first as DateParser.init_strings(self) so that the
|
||||||
@ -105,13 +105,13 @@ class DateParserFR(DateParser):
|
|||||||
override stuff from this method. See DateParserRU() as an example.
|
override stuff from this method. See DateParserRU() as an example.
|
||||||
"""
|
"""
|
||||||
DateParser.init_strings(self)
|
DateParser.init_strings(self)
|
||||||
|
|
||||||
DateParser.calendar_to_int.update({
|
DateParser.calendar_to_int.update({
|
||||||
'révolutionnaire' : Date.CAL_FRENCH,
|
'révolutionnaire' : Date.CAL_FRENCH,
|
||||||
'r' : Date.CAL_FRENCH,
|
'r' : Date.CAL_FRENCH,
|
||||||
'perse' : Date.CAL_PERSIAN,
|
'perse' : Date.CAL_PERSIAN,
|
||||||
})
|
})
|
||||||
|
|
||||||
DateParser.month_to_int.update({
|
DateParser.month_to_int.update({
|
||||||
"januaris" : 1,
|
"januaris" : 1,
|
||||||
"januarii" : 1,
|
"januarii" : 1,
|
||||||
@ -155,7 +155,7 @@ class DateParserFR(DateParser):
|
|||||||
"ernting" : 8,
|
"ernting" : 8,
|
||||||
"septembris" : 9,
|
"septembris" : 9,
|
||||||
"7bre" : 9,
|
"7bre" : 9,
|
||||||
"7bris" : 9,
|
"7bris" : 9,
|
||||||
"september" : 9,
|
"september" : 9,
|
||||||
"scheidling" : 9,
|
"scheidling" : 9,
|
||||||
"october" : 10,
|
"october" : 10,
|
||||||
@ -163,7 +163,7 @@ class DateParserFR(DateParser):
|
|||||||
"8bre" : 10,
|
"8bre" : 10,
|
||||||
"8bris" : 10,
|
"8bris" : 10,
|
||||||
"gilbhard" : 10,
|
"gilbhard" : 10,
|
||||||
"november" : 11,
|
"november" : 11,
|
||||||
"novembris" : 11,
|
"novembris" : 11,
|
||||||
"9bre" : 11,
|
"9bre" : 11,
|
||||||
"9bris" : 11,
|
"9bris" : 11,
|
||||||
@ -177,15 +177,15 @@ class DateParserFR(DateParser):
|
|||||||
"xbris" : 12,
|
"xbris" : 12,
|
||||||
"julmond" : 12,
|
"julmond" : 12,
|
||||||
"christmond" : 12,
|
"christmond" : 12,
|
||||||
})
|
})
|
||||||
|
|
||||||
# This self._numeric is different from the base
|
# This self._numeric is different from the base
|
||||||
# avoid bug gregorian / french calendar conversion (+/-10 days)
|
# avoid bug gregorian / french calendar conversion (+/-10 days)
|
||||||
|
|
||||||
self._numeric = re.compile("((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\s*$")
|
self._numeric = re.compile(r"((\d+)[/\. ])?\s*((\d+)[/\.])?\s*(\d+)\s*$")
|
||||||
self._span = re.compile("(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)",
|
self._span = re.compile(r"(de)\s+(?P<start>.+)\s+(à)\s+(?P<stop>.+)",
|
||||||
re.IGNORECASE)
|
re.IGNORECASE)
|
||||||
self._range = re.compile("(entre|ent\.|ent)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)",
|
self._range = re.compile(r"(entre|ent\.|ent)\s+(?P<start>.+)\s+(et)\s+(?P<stop>.+)",
|
||||||
re.IGNORECASE)
|
re.IGNORECASE)
|
||||||
|
|
||||||
# This self._text are different from the base
|
# This self._text are different from the base
|
||||||
@ -193,32 +193,32 @@ class DateParserFR(DateParser):
|
|||||||
|
|
||||||
#gregorian and julian
|
#gregorian and julian
|
||||||
|
|
||||||
self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
self._text2 = re.compile(r'(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
||||||
self._mon_str, re.IGNORECASE)
|
self._mon_str, re.IGNORECASE)
|
||||||
|
|
||||||
#hebrew
|
#hebrew
|
||||||
|
|
||||||
self._jtext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
self._jtext2 = re.compile(r'(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
||||||
self._jmon_str, re.IGNORECASE)
|
self._jmon_str, re.IGNORECASE)
|
||||||
|
|
||||||
#french
|
#french
|
||||||
|
|
||||||
self._ftext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
self._ftext2 = re.compile(r'(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
||||||
self._fmon_str, re.IGNORECASE)
|
self._fmon_str, re.IGNORECASE)
|
||||||
|
|
||||||
#persian
|
#persian
|
||||||
|
|
||||||
self._ptext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
self._ptext2 = re.compile(r'(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
||||||
self._pmon_str, re.IGNORECASE)
|
self._pmon_str, re.IGNORECASE)
|
||||||
|
|
||||||
#islamic
|
#islamic
|
||||||
|
|
||||||
self._itext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
self._itext2 = re.compile(r'(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
||||||
self._imon_str, re.IGNORECASE)
|
self._imon_str, re.IGNORECASE)
|
||||||
|
|
||||||
#swedish
|
#swedish
|
||||||
|
|
||||||
self._stext2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
self._stext2 = re.compile(r'(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' %
|
||||||
self._smon_str, re.IGNORECASE)
|
self._smon_str, re.IGNORECASE)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -228,7 +228,7 @@ class DateParserFR(DateParser):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class DateDisplayFR(DateDisplay):
|
class DateDisplayFR(DateDisplay):
|
||||||
"""
|
"""
|
||||||
French language date display class.
|
French language date display class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_bce_str = "%s avant le calendrier"
|
_bce_str = "%s avant le calendrier"
|
||||||
@ -239,7 +239,7 @@ class DateDisplayFR(DateDisplay):
|
|||||||
_locale_tformat = _locale_tformat.replace('%d', "J")
|
_locale_tformat = _locale_tformat.replace('%d', "J")
|
||||||
_locale_tformat = _locale_tformat.replace('%m', "M")
|
_locale_tformat = _locale_tformat.replace('%m', "M")
|
||||||
_locale_tformat = _locale_tformat.replace('%Y', "A")
|
_locale_tformat = _locale_tformat.replace('%Y', "A")
|
||||||
|
|
||||||
formats = ("AAAA-MM-JJ (ISO)", # 0
|
formats = ("AAAA-MM-JJ (ISO)", # 0
|
||||||
"Défaut système (" + _locale_tformat + ")", # 1
|
"Défaut système (" + _locale_tformat + ")", # 1
|
||||||
"Jour Mois Année", # 2
|
"Jour Mois Année", # 2
|
||||||
@ -247,8 +247,8 @@ class DateDisplayFR(DateDisplay):
|
|||||||
"Jour. Mois Année", # 4
|
"Jour. Mois Année", # 4
|
||||||
"Jour. MOI Année", # 5
|
"Jour. MOI Année", # 5
|
||||||
"Mois Jour, Année", # 6
|
"Mois Jour, Année", # 6
|
||||||
"MOI Jour, Année", # 7
|
"MOI Jour, Année",) # 7
|
||||||
)
|
|
||||||
# this definition must agree with its "_display_gregorian" method
|
# this definition must agree with its "_display_gregorian" method
|
||||||
|
|
||||||
def _display_gregorian(self, date_val, **kwargs):
|
def _display_gregorian(self, date_val, **kwargs):
|
||||||
@ -291,7 +291,7 @@ class DateDisplayFR(DateDisplay):
|
|||||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
value = "%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)
|
||||||
elif self.format == 3:
|
elif self.format == 3:
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ class DateDisplayFR(DateDisplay):
|
|||||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||||
else:
|
else:
|
||||||
|
|
||||||
value = "%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 == 4:
|
elif self.format == 4:
|
||||||
|
|
||||||
@ -318,10 +318,10 @@ class DateDisplayFR(DateDisplay):
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
# base_display :
|
# base_display :
|
||||||
# value = "%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)
|
||||||
|
|
||||||
value = "%d. %s %s" % (date_val[0],
|
value = "%d. %s %s" % (date_val[0],
|
||||||
self.long_months[date_val[1]],
|
self.long_months[date_val[1]],
|
||||||
year)
|
year)
|
||||||
elif self.format == 5:
|
elif self.format == 5:
|
||||||
@ -336,11 +336,11 @@ class DateDisplayFR(DateDisplay):
|
|||||||
else:
|
else:
|
||||||
|
|
||||||
# base_display :
|
# base_display :
|
||||||
# value = "%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)
|
||||||
|
|
||||||
value = "%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 == 6:
|
elif self.format == 6:
|
||||||
|
|
||||||
# month_name day, year
|
# month_name day, year
|
||||||
@ -367,12 +367,12 @@ class DateDisplayFR(DateDisplay):
|
|||||||
date_val[0], year)
|
date_val[0], year)
|
||||||
else:
|
else:
|
||||||
return self.display_iso(date_val)
|
return self.display_iso(date_val)
|
||||||
|
|
||||||
if date_val[2] < 0:
|
if date_val[2] < 0:
|
||||||
return self._bce_str % value
|
return self._bce_str % value
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
display = DateDisplay.display_formatted
|
display = DateDisplay.display_formatted
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -382,4 +382,4 @@ class DateDisplayFR(DateDisplay):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
register_datehandler(('fr_FR', 'fr', 'french', 'French', 'fr_CA',
|
register_datehandler(('fr_FR', 'fr', 'french', 'French', 'fr_CA',
|
||||||
'fr_BE', 'fr_CH'), DateParserFR, DateDisplayFR)
|
'fr_BE', 'fr_CH'), DateParserFR, DateDisplayFR)
|
||||||
|
Loading…
Reference in New Issue
Block a user