4089: Month names for Lithuanian (contribution by embar)

svn: r16574
This commit is contained in:
Jérôme Rapinat 2011-02-05 08:29:45 +00:00
parent 577fb388c5
commit 1630036075

View File

@ -48,6 +48,59 @@ from _DateHandler import register_datehandler
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class DateParserLT(DateParser): class DateParserLT(DateParser):
"""
Convert a text string into a Date object. If the date cannot be
converted, the text string is assigned.
"""
month_to_int = DateParser.month_to_int
# Custom months not the same as long months
month_to_int[u"sausis"] = 1
month_to_int[u"vasaris"] = 2
month_to_int[u"kovas"] = 3
month_to_int[u"balandis"] = 4
month_to_int[u"gegužė"] = 5
month_to_int[u"gegužis"] = 5
month_to_int[u"birželis"] = 6
month_to_int[u"liepa"] = 7
month_to_int[u"rugpjūtis"] = 8
month_to_int[u"rugsėjis"] = 9
month_to_int[u"spalis"] = 10
month_to_int[u"lapkritis"] = 11
month_to_int[u"gruodis"] = 12
# For not full months
month_to_int[u"saus"] = 1
month_to_int[u"vasa"] = 2
month_to_int[u"vasar"] = 2
month_to_int[u"bala"] = 4
month_to_int[u"balan"] = 4
month_to_int[u"baland"] = 4
month_to_int[u"gegu"] = 5
month_to_int[u"geguž"] = 5
month_to_int[u"birž"] = 6
month_to_int[u"birže"] = 6
month_to_int[u"biržel"] = 6
month_to_int[u"liep"] = 7
month_to_int[u"rugp"] = 8
month_to_int[u"rugpj"] = 8
month_to_int[u"rugpjū"] = 8
month_to_int[u"rugpjūt"] = 8
month_to_int[u"rugs"] = 9
month_to_int[u"rugsė"] = 9
month_to_int[u"rugsėj"] = 9
month_to_int[u"rugsėjis"] = 9
month_to_int[u"spal"] = 10
month_to_int[u"lapk"] = 11
month_to_int[u"lapkr"] = 11
month_to_int[u"lapkri"] = 11
month_to_int[u"lapkrit"] = 11
month_to_int[u"gru"] = 12
month_to_int[u"gruo"] = 12
month_to_int[u"gruod"] = 12
modifier_to_int = { modifier_to_int = {
u'prieš' : Date.MOD_BEFORE, u'prieš' : Date.MOD_BEFORE,
@ -64,11 +117,11 @@ class DateParserLT(DateParser):
u'h' : Date.CAL_HEBREW, u'h' : Date.CAL_HEBREW,
u'islamo' : Date.CAL_ISLAMIC, u'islamo' : Date.CAL_ISLAMIC,
u'i' : Date.CAL_ISLAMIC, u'i' : Date.CAL_ISLAMIC,
u'prancuzų respublikos': Date.CAL_FRENCH, u'prancūzų respublikos': Date.CAL_FRENCH,
u'r' : Date.CAL_FRENCH, u'r' : Date.CAL_FRENCH,
u'persų' : Date.CAL_PERSIAN, u'persų' : Date.CAL_PERSIAN,
u'p' : Date.CAL_PERSIAN, u'p' : Date.CAL_PERSIAN,
u'swedish' : Date.CAL_SWEDISH, u'švedų' : Date.CAL_SWEDISH,
u's' : Date.CAL_SWEDISH, u's' : Date.CAL_SWEDISH,
} }
@ -92,6 +145,27 @@ class DateParserLT(DateParser):
('|'.join(_range_1), '|'.join(_range_2)), ('|'.join(_range_1), '|'.join(_range_2)),
re.IGNORECASE) re.IGNORECASE)
#------------------------------------------------------------------------
#
# FIXME: oficial long date format (ex, 2011 m. vasario 4 d.)
# is not recognized correctly:
# with self._text2 - day is recognized as year, year - as day
# with self._iso - month not recognized, day recognized,
# year increased by 1, date treated as double
# TODO: in _DateParser.py in _parse_calendar modify groups
#
#------------------------------------------------------------------------
#
# # gregorian and julian
#
# self._text2 = re.compile('(\d+)?\s*?m\.?\s*?%s\.?\s*((\d+)(/\d+)?)?\s*?d?\.?' %
# self._mon_str, re.IGNORECASE)
#
# self._iso = re.compile('(\d+)(/\d+)?\s*?m?\.?\s+?%s\.?\s*((\d+))?\s*?d?\.?' %
# self._mon_str, re.IGNORECASE)
#
#-------------------------------------------------------------------------
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# Lithuanian displayer # Lithuanian displayer
@ -101,17 +175,22 @@ class DateDisplayLT(DateDisplay):
""" """
Lithuanian language date display class. Lithuanian language date display class.
""" """
long_months = ( u"", u"sausio", u"vasario", u"kovo", u"balandžio", u"gegužės", long_months = ( u"", u"sausio", u"vasario", u"kovo", u"balandžio", u"gegužės",
u"birželio", u"liepos", u"rugpjūčio", u"rugsėjo", u"spalio", u"birželio", u"liepos", u"rugpjūčio", u"rugsėjo", u"spalio",
u"lapkričio", u"gruodžio" ) u"lapkričio", u"gruodžio" )
long_months_vardininkas = ( u"", u"sausis", u"vasaris", u"kovas", u"balandis", u"gegužė",
u"birželis", u"liepa", u"rugpjūtis", u"rugsėjis", u"spalis",
u"lapkritis", u"gruodis" )
short_months = ( u"", u"Sau", u"Vas", u"Kov", u"Bal", u"Geg", u"Bir", short_months = ( u"", u"Sau", u"Vas", u"Kov", u"Bal", u"Geg", u"Bir",
u"Lie", u"Rgp", u"Rgs", u"Spa", u"Lap", u"Grd" ) u"Lie", u"Rgp", u"Rgs", u"Spa", u"Lap", u"Grd" )
calendar = ( calendar = (
u"", u"julijaus", u"", u"julijaus",
u"hebrajų", u"hebrajų",
u"prancuzų respublikos", u"prancūzų respublikos",
u"persų", u"persų",
u"islamo", u"islamo",
u"švedų" u"švedų"
@ -126,9 +205,45 @@ class DateDisplayLT(DateDisplay):
_qual_str = (u"", u"apytikriai ", u"apskaičiuota ") _qual_str = (u"", u"apytikriai ", u"apskaičiuota ")
formats = ( formats = (
"YYYY-MM-DD (ISO)", "Skaitmeninis", "Mėnuo Diena, Metai", "mmmm-MM-DD (ISO)", "mmmm m. mėnesio diena d.", "Mėn diena, metai")
"Mėn DD, YYYY", "Diena Mėnuo Metai", "DD Mėn YYYY"
) def _display_gregorian(self, date_val):
"""
display gregorian calendar date in different format
"""
year = self._slash_year(date_val[2], date_val[3])
if self.format == 0:
return self.display_iso(date_val)
elif self.format == 1:
# mmmm m. mėnesio diena d. (YYYY m. month DD d.)
if date_val[0] == 0:
if date_val[1] == 0:
value = year
else:
value = "%s m. %s" % (year, self.long_months_vardininkas[date_val[1]])
else:
value = "%s m. %s %d d." % (year, self.long_months[date_val[1]],
date_val[0])
elif self.format == 2:
# MON Day, Year
if date_val[0] == 0:
if date_val[1] == 0:
value = year
else:
value = "%s %s" % (self.short_months[date_val[1]], year)
else:
value = "%s %d, %s" % (self.short_months[date_val[1]],
date_val[0], year)
if date_val[2] < 0:
return self._bce_str % value
else:
return value
def display(self, date): def display(self, date):
""" """