Make short and long month strings constants in the DateDisplay class instead of using the localized month strings detected by GrampsLocale. This will allow DateDisplayers to work for languages other than the current locale - will be useful for user selectable report translations.
svn: r13436
This commit is contained in:
parent
d920e3479a
commit
758d69ec88
@ -90,8 +90,8 @@ QUAL_TEXT = (
|
||||
(Date.QUAL_CALCULATED, _('Calculated')) )
|
||||
|
||||
CAL_TO_MONTHS_NAMES = {
|
||||
Date.CAL_GREGORIAN : DateHandler.displayer.MONS,
|
||||
Date.CAL_JULIAN : DateHandler.displayer.MONS,
|
||||
Date.CAL_GREGORIAN : DateHandler.displayer.short_months,
|
||||
Date.CAL_JULIAN : DateHandler.displayer.short_months,
|
||||
Date.CAL_HEBREW : DateHandler.displayer.hebrew,
|
||||
Date.CAL_FRENCH : DateHandler.displayer.french,
|
||||
Date.CAL_PERSIAN : DateHandler.displayer.persian,
|
||||
|
@ -47,9 +47,15 @@ import GrampsLocale
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplay(object):
|
||||
|
||||
_months = GrampsLocale.long_months
|
||||
MONS = GrampsLocale.short_months
|
||||
"""
|
||||
Base date display class.
|
||||
"""
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
_tformat = GrampsLocale.tformat
|
||||
|
||||
@ -120,7 +126,6 @@ class DateDisplay(object):
|
||||
self._display_islamic,
|
||||
self._display_swedish]
|
||||
|
||||
self.verify_format(format)
|
||||
if format is None:
|
||||
self.format = 0
|
||||
else:
|
||||
@ -129,19 +134,6 @@ class DateDisplay(object):
|
||||
def set_format(self, format):
|
||||
self.format = format
|
||||
|
||||
def verify_format(self, format):
|
||||
pass
|
||||
|
||||
def quote_display(self, date):
|
||||
"""
|
||||
Similar to the display task, except that if the value is a text only
|
||||
value, it is enclosed in quotes.
|
||||
"""
|
||||
if date.get_modifier() == Date.MOD_TEXTONLY:
|
||||
return '"%s"' % self.display(date)
|
||||
else:
|
||||
return self.display(date)
|
||||
|
||||
def format_extras(self, cal, newyear):
|
||||
"""
|
||||
Formats the extra items (calendar, newyear) for a date.
|
||||
@ -243,9 +235,9 @@ class DateDisplay(object):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]], year)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._months[date_val[1]],
|
||||
value = "%s %d, %s" % (self.long_months[date_val[1]],
|
||||
date_val[0], year)
|
||||
elif self.format == 3:
|
||||
# MON Day, Year
|
||||
@ -253,9 +245,9 @@ class DateDisplay(object):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self.MONS[date_val[1]],
|
||||
value = "%s %d, %s" % (self.short_months[date_val[1]],
|
||||
date_val[0], year)
|
||||
elif self.format == 4:
|
||||
# Day Month Year
|
||||
@ -263,19 +255,20 @@ class DateDisplay(object):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]], year)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0], self._months[date_val[1]],
|
||||
year)
|
||||
value = "%d %s %s" % (date_val[0],
|
||||
self.long_months[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)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
value = "%d %s %s" % (date_val[0],
|
||||
self.short_months[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
@ -296,7 +289,8 @@ class DateDisplay(object):
|
||||
else:
|
||||
value = u"%s %d" % (month_list[date_val[1]], year)
|
||||
else:
|
||||
value = u"%s %d, %s" % (month_list[date_val[1]], date_val[0], year)
|
||||
value = u"%s %d, %s" % (month_list[date_val[1]], date_val[0],
|
||||
year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
@ -313,7 +307,8 @@ class DateDisplay(object):
|
||||
else:
|
||||
value = u"%s %d" % (self.french[date_val[1]], year)
|
||||
else:
|
||||
value = u"%d %s %s" % (date_val[0], self.french[date_val[1]], year)
|
||||
value = u"%d %s %s" % (date_val[0], self.french[date_val[1]],
|
||||
year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
|
@ -30,6 +30,7 @@ Class handling language-specific selection for date parser and displayer.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import locale
|
||||
import os
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -53,6 +54,10 @@ from _DateDisplay import DateDisplay, DateDisplayEn
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
LANG = locale.getlocale(locale.LC_TIME)[0]
|
||||
if not LANG:
|
||||
if "LANG" in os.environ:
|
||||
LANG = os.environ["LANG"]
|
||||
|
||||
if LANG:
|
||||
LANG_SHORT = LANG.split('_')[0]
|
||||
else:
|
||||
|
@ -80,17 +80,3 @@ def get_date(date_base) :
|
||||
def get_date_valid(date_base):
|
||||
date_obj = date_base.get_date_object()
|
||||
return date_obj.get_valid()
|
||||
|
||||
def get_quote_date(date_base):
|
||||
"""
|
||||
Return a string representation of the date of the DateBase instance.
|
||||
|
||||
This representation is based off the default date display format
|
||||
determined by the locale's DateDisplay instance. The date is
|
||||
enclosed in quotes if the Date is not a valid date.
|
||||
|
||||
@return: Returns a string representing the DateBase date
|
||||
@rtype: str
|
||||
|
||||
"""
|
||||
return displayer.quote_display(date_base.get_date_object())
|
||||
|
@ -113,6 +113,16 @@ class DateParserCA(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayCA(DateDisplay):
|
||||
"""
|
||||
Catalan language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (Julià)", u" (Hebreu)",
|
||||
|
@ -99,6 +99,16 @@ class DateParserCZ(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayCZ(DateDisplay):
|
||||
"""
|
||||
Czech language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (juliánský)", u" (hebrejský)",
|
||||
|
@ -44,13 +44,14 @@ from _DateHandler import register_datehandler
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# French parser
|
||||
# German parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateParserDE(DateParser):
|
||||
|
||||
month_to_int = DateParser.month_to_int
|
||||
# Always add german and austrian name variants no matter what the current locale is
|
||||
# Always add german and austrian name variants no matter what the current
|
||||
# locale is
|
||||
month_to_int[u"januar"] = 1
|
||||
month_to_int[u"jan"] = 1
|
||||
month_to_int[u"jänner"] = 1
|
||||
@ -129,10 +130,20 @@ class DateParserDE(DateParser):
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# French display
|
||||
# German display
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayDE(DateDisplay):
|
||||
"""
|
||||
German language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (julianisch)", u" (hebräisch)",
|
||||
@ -171,36 +182,40 @@ class DateDisplayDE(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]], year)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._months[date_val[1]], date_val[0], year)
|
||||
value = "%s %d, %s" % (self.long_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)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self.MONS[date_val[1]], date_val[0], year)
|
||||
value = "%s %d, %s" % (self.short_months[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)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d. %s %s" % (date_val[0], self._months[date_val[1]], year)
|
||||
value = "%d. %s %s" % (date_val[0],
|
||||
self.long_months[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)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d. %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
value = "%d. %s %s" % (date_val[0],
|
||||
self.short_months[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
|
@ -114,6 +114,16 @@ class DateParserES(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayES(DateDisplay):
|
||||
"""
|
||||
Spanish language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"enero", u"febrero", u"marzo", u"abril", u"mayo",
|
||||
u"junio", u"julio", u"agosto", u"septiembre", u"octubre",
|
||||
u"noviembre", u"diciembre" )
|
||||
|
||||
short_months = ( u"enero", u"feb.", u"marzo", u"abr.", u"mayo", u"jun.",
|
||||
u"jul.", u"agosto", u"set.", u"oct.", u"nov.", u"dic" )
|
||||
|
||||
calendar = (
|
||||
"", u" (Juliano)", u" (Hebreo)",
|
||||
|
@ -113,7 +113,17 @@ class DateParserFI(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayFI(DateDisplay):
|
||||
|
||||
"""
|
||||
Finnish language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = ("",
|
||||
u"(juliaaninen)",
|
||||
u"(heprealainen)",
|
||||
|
@ -50,8 +50,6 @@ from _DateHandler import register_datehandler
|
||||
# French parser
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DateParserFR(DateParser):
|
||||
"""
|
||||
Convert a text string into a Date object. If the date cannot be
|
||||
@ -238,12 +236,17 @@ class DateParserFR(DateParser):
|
||||
# French display
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class DateDisplayFR(DateDisplay):
|
||||
"""
|
||||
French language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = ("", u" (Julien)", u" (Hébreu)", u" (Révolutionnaire)",
|
||||
u" (Perse)", u" (Islamique)", u" (Suédois)")
|
||||
@ -288,10 +291,10 @@ class DateDisplayFR(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % ((self._months)[date_val[1]], year)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % ((self._months)[date_val[1]],
|
||||
date_val[0], year)
|
||||
value = "%s %d, %s" % (self.long_months[date_val[1]],
|
||||
date_val[0], year)
|
||||
elif self.format == 3:
|
||||
|
||||
# MON Day, Year
|
||||
@ -300,10 +303,10 @@ class DateDisplayFR(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % ((self.MONS)[date_val[1]], year)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % ((self.MONS)[date_val[1]],
|
||||
date_val[0], year)
|
||||
value = "%s %d, %s" % (self.short_months[date_val[1]],
|
||||
date_val[0], year)
|
||||
elif self.format == 4:
|
||||
|
||||
# Day. Month Year
|
||||
@ -312,13 +315,15 @@ class DateDisplayFR(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % ((self._months)[date_val[1]], year)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
|
||||
# base_display :
|
||||
# value = "%d %s %s" % (date_val[0], self._months[date_val[1]], year)
|
||||
# value = "%d %s %s" % (date_val[0],
|
||||
# self.long_months[date_val[1]], year)
|
||||
|
||||
value = "%d. %s %s" % (date_val[0], (self._months)[date_val[1]],
|
||||
value = "%d. %s %s" % (date_val[0],
|
||||
self.long_months[date_val[1]],
|
||||
year)
|
||||
elif self.format == 5:
|
||||
|
||||
@ -328,14 +333,15 @@ class DateDisplayFR(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % ((self.MONS)[date_val[1]], year)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
|
||||
# base_display :
|
||||
# value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
# value = "%d %s %s" % (date_val[0],
|
||||
# self.short_months[date_val[1]], year)
|
||||
|
||||
value = "%d.%s %s" % (date_val[0], (self.MONS)[date_val[1]],
|
||||
year)
|
||||
value = "%d.%s %s" % (date_val[0],
|
||||
self.short_months[date_val[1]], year)
|
||||
|
||||
elif self.format == 6:
|
||||
|
||||
@ -345,11 +351,11 @@ class DateDisplayFR(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % ((self._months)[date_val[1]], year)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
|
||||
value = "%d %s %s" % (date_val[0], (self._months)[date_val[1]],
|
||||
year)
|
||||
value = "%d %s %s" % (date_val[0],
|
||||
self.long_months[date_val[1]], year)
|
||||
else:
|
||||
|
||||
# Day MON Year
|
||||
@ -358,11 +364,11 @@ class DateDisplayFR(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % ((self.MONS)[date_val[1]], year)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
|
||||
value = "%d %s %s" % (date_val[0], (self.MONS)[date_val[1]],
|
||||
year)
|
||||
value = "%d %s %s" % (date_val[0],
|
||||
self.short_months[date_val[1]], year)
|
||||
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
|
@ -201,8 +201,16 @@ class DateParserHR(DateParser):
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayHR(DateDisplay):
|
||||
"""
|
||||
Croatian date display class
|
||||
Croatian language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (julijanski)", u" (hebrejski)",
|
||||
u" (francuski republikanski)", u" (perzijski)", u" (islamski)",
|
||||
|
@ -109,7 +109,17 @@ class DateParserIT(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayIT(DateDisplay):
|
||||
|
||||
"""
|
||||
Italian language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (Giuliano)", u" (Ebraico)",
|
||||
u" (Rivoluzionario)", u" (Persiano)", u" (Islamico)",
|
||||
|
@ -98,7 +98,17 @@ class DateParserLT(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayLT(DateDisplay):
|
||||
|
||||
"""
|
||||
Lithuanian language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
u"", u" (julijaus)",
|
||||
u" (hebrajų)",
|
||||
|
@ -105,6 +105,13 @@ class DateDisplayNb(DateDisplay):
|
||||
"""
|
||||
Norwegian language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
formats = (
|
||||
u"ÅÅÅÅ-MM-DD (ISO)",
|
||||
|
@ -135,7 +135,17 @@ class DateParserNL(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayNL(DateDisplay):
|
||||
|
||||
"""
|
||||
Dutch language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (juliaans)", u" (hebreeuws)",
|
||||
u" (franse republiek)", u" (persisch)", u" (islamitisch)",
|
||||
@ -174,36 +184,40 @@ class DateDisplayNL(DateDisplay):
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self._months[date_val[1]], year)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._months[date_val[1]], date_val[0], year)
|
||||
value = "%s %d, %s" % (self.long_months[date_val[1]],
|
||||
date_val[0], year)
|
||||
elif self.format == 3:
|
||||
# Mnd Day, Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self.MONS[date_val[1]], date_val[0], year)
|
||||
value = "%s %d, %s" % (self.short_months[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)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0], self._months[date_val[1]], year)
|
||||
value = "%d %s %s" % (date_val[0],
|
||||
self.long_months[date_val[1]], year)
|
||||
else:
|
||||
# Day Mnd Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self.MONS[date_val[1]], year)
|
||||
value = "%s %s" % (self.short_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0], self.MONS[date_val[1]], year)
|
||||
value = "%d %s %s" % (date_val[0],
|
||||
self.short_months[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
|
@ -136,16 +136,26 @@ class DateParserPL(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayPL(DateDisplay):
|
||||
|
||||
"""
|
||||
Polish language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (juliański)", u" (hebrajski)",
|
||||
u" (francuski republikański)", u" (perski)", u" (islamski)",
|
||||
u" (swedish)"
|
||||
)
|
||||
|
||||
_mod_str = ("",u"przed ",u"po ",u"ok. ","","","")
|
||||
_mod_str = ("", u"przed ", u"po ", u"ok. ", "", "", "")
|
||||
|
||||
_qual_str = ("",u"szacowany ",u"obliczony ")
|
||||
_qual_str = ("", u"szacowany ", u"obliczony ")
|
||||
|
||||
_bce_str = "%s p.n.e."
|
||||
|
||||
@ -170,8 +180,8 @@ class DateDisplayPL(DateDisplay):
|
||||
"XII"
|
||||
)
|
||||
|
||||
def _display_gregorian(self,date_val):
|
||||
year = self._slash_year(date_val[2],date_val[3])
|
||||
def _display_gregorian(self, date_val):
|
||||
year = self._slash_year(date_val[2], date_val[3])
|
||||
if self.format == 0:
|
||||
return self.display_iso(date_val)
|
||||
elif self.format == 1:
|
||||
@ -181,51 +191,54 @@ class DateDisplayPL(DateDisplay):
|
||||
if date_val[0] == date_val[1] == 0:
|
||||
value = str(date_val[2])
|
||||
else:
|
||||
value = self._tformat.replace('%m',str(date_val[0]))
|
||||
value = value.replace('%d',str(date_val[1]))
|
||||
value = value.replace('%y',str(date_val[2]))
|
||||
value = self._tformat.replace('%m', str(date_val[0]))
|
||||
value = value.replace('%d', str(date_val[1]))
|
||||
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)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%s %d, %s" % (self._months[date_val[1]],date_val[0],year)
|
||||
value = "%s %d, %s" % (self.long_months[date_val[1]],
|
||||
date_val[0], year)
|
||||
elif self.format == 3:
|
||||
# Day. Month. Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%d.%s" % (date_val[1],year)
|
||||
value = "%d.%s" % (date_val[1], year)
|
||||
else:
|
||||
value = "%d.%d.%s" % (date_val[0],date_val[1],year)
|
||||
value = "%d.%d.%s" % (date_val[0], date_val[1], 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)
|
||||
value = "%s %s" % (self.long_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0],self._months[date_val[1]],year)
|
||||
value = "%d %s %s" % (date_val[0],
|
||||
self.long_months[date_val[1]], year)
|
||||
else:
|
||||
# Day RomanMon Year
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
value = year
|
||||
else:
|
||||
value = "%s %s" % (self.roman_months[date_val[1]],year)
|
||||
value = "%s %s" % (self.roman_months[date_val[1]], year)
|
||||
else:
|
||||
value = "%d %s %s" % (date_val[0],self.roman_months[date_val[1]],year)
|
||||
value = "%d %s %s" % (date_val[0],
|
||||
self.roman_months[date_val[1]], year)
|
||||
if date_val[2] < 0:
|
||||
return self._bce_str % value
|
||||
else:
|
||||
return value
|
||||
|
||||
def display(self,date):
|
||||
def display(self, date):
|
||||
"""
|
||||
Return a text string representing the date.
|
||||
"""
|
||||
@ -243,14 +256,17 @@ class DateDisplayPL(DateDisplay):
|
||||
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'od',d1,u'do',d2,self.calendar[cal])
|
||||
return "%s%s %s %s %s%s" % (qual_str, u'od', d1, u'do', 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 %s%s" % (qual_str,u'między',d1,u'a',d2,self.calendar[cal])
|
||||
return "%s%s %s %s %s%s" % (qual_str, u'między', d1, u'a', 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])
|
||||
return "%s%s%s%s" % (qual_str, self._mod_str[mod], text,
|
||||
self.calendar[cal])
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -113,7 +113,17 @@ class DateParserPT(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayPT(DateDisplay):
|
||||
|
||||
"""
|
||||
Portuguese language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (Juliano)", u" (Hebreu)",
|
||||
u" (Revolucionário)", u" (Persa)", u" (Islâmico)",
|
||||
|
@ -184,7 +184,17 @@ class DateParserRU(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplayRU(DateDisplay):
|
||||
|
||||
"""
|
||||
Russian language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
u"",
|
||||
u" (юлианский)",
|
||||
|
@ -101,7 +101,17 @@ class DateParserSK(DateParser):
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class DateDisplaySK(DateDisplay):
|
||||
|
||||
"""
|
||||
Slovak language date display class.
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (juliánský)", u" (hebrejský)",
|
||||
u" (republikánsky)", u" (perzský)", u" (islamský)",
|
||||
|
@ -234,6 +234,14 @@ class DateDisplaySR_latin(DateDisplay):
|
||||
"""
|
||||
Serbian (latin) date display class
|
||||
"""
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
calendar = (
|
||||
"", u" (julijanski)", u" (hebrejski)",
|
||||
u" (francuski republikanski)", u" (persijski)", u" (islamski)",
|
||||
|
@ -111,7 +111,14 @@ class DateDisplaySv(DateDisplay):
|
||||
"""
|
||||
Swedish language date display class.
|
||||
"""
|
||||
|
||||
# TODO: Translate these month strings:
|
||||
long_months = ( u"January", u"February", u"March", u"April", u"May",
|
||||
u"June", u"July", u"August", u"September", u"October",
|
||||
u"November", u"December" )
|
||||
|
||||
short_months = ( u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun", u"Jul",
|
||||
u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
||||
|
||||
formats = (
|
||||
u"YYYY-MM-DD (ISO)",
|
||||
u"Numerisk",
|
||||
|
Loading…
Reference in New Issue
Block a user