2004-11-16 09:14:23 +05:30
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
#
|
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
|
#
|
2006-02-04 03:33:53 +05:30
|
|
|
|
# Copyright (C) 2004-2006 Donald N. Allingham
|
2004-11-16 09:14:23 +05:30
|
|
|
|
#
|
|
|
|
|
# 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.
|
|
|
|
|
#
|
2007-06-27 10:20:33 +05:30
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
2004-11-16 09:14:23 +05:30
|
|
|
|
# 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
|
|
|
|
|
#
|
|
|
|
|
|
2008-02-24 19:25:55 +05:30
|
|
|
|
# $Id:_Date_ru.py 9912 2008-01-22 09:17:46Z acraphae $
|
2004-11-16 09:14:23 +05:30
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
Russian-specific classes for parsing and displaying dates.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Python modules
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# GRAMPS modules
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
2007-10-08 22:11:39 +05:30
|
|
|
|
from gen.lib import Date
|
2006-03-11 10:28:58 +05:30
|
|
|
|
from _DateParser import DateParser
|
|
|
|
|
from _DateDisplay import DateDisplay
|
|
|
|
|
from _DateHandler import register_datehandler
|
2004-11-16 09:14:23 +05:30
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Russian parser
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
class DateParserRU(DateParser):
|
|
|
|
|
|
|
|
|
|
modifier_to_int = {
|
2006-05-02 02:41:26 +05:30
|
|
|
|
u'перед' : Date.MOD_BEFORE,
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u'по' : Date.MOD_BEFORE,
|
|
|
|
|
u'после' : Date.MOD_AFTER,
|
|
|
|
|
u'п.' : Date.MOD_AFTER,
|
|
|
|
|
u'п' : Date.MOD_AFTER,
|
|
|
|
|
u'с' : Date.MOD_AFTER,
|
|
|
|
|
u'ок' : Date.MOD_ABOUT,
|
|
|
|
|
u'ок.' : Date.MOD_ABOUT,
|
|
|
|
|
u'около' : Date.MOD_ABOUT,
|
|
|
|
|
u'примерно' : Date.MOD_ABOUT,
|
|
|
|
|
u'прим' : Date.MOD_ABOUT,
|
|
|
|
|
u'прим.' : Date.MOD_ABOUT,
|
|
|
|
|
u'приблизительно' : Date.MOD_ABOUT,
|
|
|
|
|
u'приб.' : Date.MOD_ABOUT,
|
|
|
|
|
u'прибл.' : Date.MOD_ABOUT,
|
|
|
|
|
u'приб' : Date.MOD_ABOUT,
|
|
|
|
|
u'прибл' : Date.MOD_ABOUT,
|
2004-11-16 09:14:23 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
calendar_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u'григорианский' : Date.CAL_GREGORIAN,
|
|
|
|
|
u'г' : Date.CAL_GREGORIAN,
|
|
|
|
|
u'юлианский' : Date.CAL_JULIAN,
|
|
|
|
|
u'ю' : Date.CAL_JULIAN,
|
|
|
|
|
u'еврейский' : Date.CAL_HEBREW,
|
|
|
|
|
u'е' : Date.CAL_HEBREW,
|
|
|
|
|
u'исламский' : Date.CAL_ISLAMIC,
|
|
|
|
|
u'и' : Date.CAL_ISLAMIC,
|
|
|
|
|
u'республиканский': Date.CAL_FRENCH,
|
|
|
|
|
u'р' : Date.CAL_FRENCH,
|
|
|
|
|
u'персидский' : Date.CAL_PERSIAN,
|
|
|
|
|
u'п' : Date.CAL_PERSIAN,
|
2009-01-20 21:08:29 +05:30
|
|
|
|
u'swedish' : Date.CAL_SWEDISH,
|
|
|
|
|
u's' : Date.CAL_SWEDISH,
|
2004-11-16 09:14:23 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quality_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u'оценено' : Date.QUAL_ESTIMATED,
|
|
|
|
|
u'оцен.' : Date.QUAL_ESTIMATED,
|
|
|
|
|
u'оц.' : Date.QUAL_ESTIMATED,
|
|
|
|
|
u'оцен' : Date.QUAL_ESTIMATED,
|
|
|
|
|
u'оц' : Date.QUAL_ESTIMATED,
|
|
|
|
|
u'вычислено' : Date.QUAL_CALCULATED,
|
|
|
|
|
u'вычисл.' : Date.QUAL_CALCULATED,
|
|
|
|
|
u'выч.' : Date.QUAL_CALCULATED,
|
|
|
|
|
u'вычисл' : Date.QUAL_CALCULATED,
|
|
|
|
|
u'выч' : Date.QUAL_CALCULATED,
|
2004-11-16 09:14:23 +05:30
|
|
|
|
}
|
|
|
|
|
|
2006-05-02 02:41:26 +05:30
|
|
|
|
hebrew_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u"тишрей":1,
|
|
|
|
|
u"хешван":2,
|
|
|
|
|
u"кислев":3,
|
|
|
|
|
u"тевет":4,
|
|
|
|
|
u"шеват":5,
|
|
|
|
|
u"адар":6,
|
|
|
|
|
u"адар бет":7,
|
|
|
|
|
u"нисан":8,
|
|
|
|
|
u"ияр":9,
|
|
|
|
|
u"сиван":10,
|
|
|
|
|
u"таммуз":11,
|
|
|
|
|
u"ав":12,
|
|
|
|
|
u"элул":13,
|
2006-05-02 02:41:26 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
islamic_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u"мухаррам":1,
|
|
|
|
|
u"сафар":2,
|
|
|
|
|
u"раби-аль-авваль":3,
|
|
|
|
|
u"раби-ассани":4,
|
|
|
|
|
u"джумада-аль-уля":5,
|
|
|
|
|
u"джумада-аль-ахира":6,
|
|
|
|
|
u"раджаб":7,
|
|
|
|
|
u"шаабан":8,
|
|
|
|
|
u"рамадан":9,
|
|
|
|
|
u"шавваль":10,
|
|
|
|
|
u"зуль-каада":11,
|
|
|
|
|
u"зуль-хиджжа":12,
|
2006-05-02 02:41:26 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
persian_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u"фарвардин":1,
|
|
|
|
|
u"урдбихишт":2,
|
|
|
|
|
u"хурдад":3,
|
|
|
|
|
u"тир":4,
|
|
|
|
|
u"мурдад":5,
|
|
|
|
|
u"шахривар":6,
|
|
|
|
|
u"михр":7,
|
|
|
|
|
u"абан":8,
|
|
|
|
|
u"азар":9,
|
|
|
|
|
u"дай":10,
|
|
|
|
|
u"бахман":11,
|
|
|
|
|
u"исфаидармуз":12,
|
2006-05-02 02:41:26 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
french_to_int = {
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u"вандемьер":1,
|
|
|
|
|
u"брюмер":2,
|
|
|
|
|
u"фример":3,
|
|
|
|
|
u"нивоз":4,
|
2006-05-02 02:41:26 +05:30
|
|
|
|
u"плювиоз":5,
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u"вантоз":6,
|
|
|
|
|
u"жерминаль":7,
|
|
|
|
|
u"флореаль":8,
|
|
|
|
|
u"прериаль":9,
|
|
|
|
|
u"мессидор":10,
|
|
|
|
|
u"термидор":11,
|
|
|
|
|
u"фрюктидор":12,
|
|
|
|
|
u"дополнит.":13,
|
2006-05-02 02:41:26 +05:30
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bce = [
|
|
|
|
|
u'до нашей эры', u'до н. э.', u'до н.э.',
|
|
|
|
|
u'до н э', u'до нэ'] + DateParser.bce
|
|
|
|
|
|
2004-11-16 09:14:23 +05:30
|
|
|
|
def init_strings(self):
|
|
|
|
|
DateParser.init_strings(self)
|
2007-06-27 10:20:33 +05:30
|
|
|
|
_span_1 = [u'с', u'от']
|
2006-05-02 02:41:26 +05:30
|
|
|
|
_span_2 = [u'по']
|
2007-06-27 10:20:33 +05:30
|
|
|
|
_range_1 = [u'между', u'меж\.', u'меж']
|
2004-11-17 09:06:18 +05:30
|
|
|
|
_range_2 = [u'и']
|
2005-06-05 09:31:56 +05:30
|
|
|
|
self._span = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
2007-06-27 10:20:33 +05:30
|
|
|
|
('|'.join(_span_1), '|'.join(_span_2)),
|
|
|
|
|
re.IGNORECASE)
|
2005-06-05 09:31:56 +05:30
|
|
|
|
self._range = re.compile("(%s)\s+(?P<start>.+)\s+(%s)\s+(?P<stop>.+)" %
|
2007-06-27 10:20:33 +05:30
|
|
|
|
('|'.join(_range_1), '|'.join(_range_2)),
|
|
|
|
|
re.IGNORECASE)
|
|
|
|
|
|
2004-11-16 09:14:23 +05:30
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Russian displayer
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
class DateDisplayRU(DateDisplay):
|
2009-10-28 08:55:57 +05:30
|
|
|
|
"""
|
|
|
|
|
Russian language date display class.
|
|
|
|
|
"""
|
|
|
|
|
# TODO: Translate these month strings:
|
2009-10-28 17:51:37 +05:30
|
|
|
|
long_months = ( u"", u"January", u"February", u"March", u"April", u"May",
|
2009-10-28 08:55:57 +05:30
|
|
|
|
u"June", u"July", u"August", u"September", u"October",
|
|
|
|
|
u"November", u"December" )
|
|
|
|
|
|
2009-10-28 17:51:37 +05:30
|
|
|
|
short_months = ( u"", u"Jan", u"Feb", u"Mar", u"Apr", u"May", u"Jun",
|
|
|
|
|
u"Jul", u"Aug", u"Sep", u"Oct", u"Nov", u"Dec" )
|
2009-10-28 08:55:57 +05:30
|
|
|
|
|
2004-11-16 09:14:23 +05:30
|
|
|
|
calendar = (
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u"",
|
2006-05-02 02:41:26 +05:30
|
|
|
|
u" (юлианский)",
|
2004-11-17 09:06:18 +05:30
|
|
|
|
u" (еврейский)",
|
|
|
|
|
u" (республиканский)",
|
|
|
|
|
u" (персидский)",
|
2009-01-20 21:08:29 +05:30
|
|
|
|
u" (исламский)",
|
|
|
|
|
u" (Swedish)"
|
2004-11-16 09:14:23 +05:30
|
|
|
|
)
|
|
|
|
|
|
2006-05-02 02:41:26 +05:30
|
|
|
|
_mod_str = (
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u"",
|
|
|
|
|
u"перед ",
|
|
|
|
|
u"после ",
|
|
|
|
|
u"около ",
|
|
|
|
|
u"", u"", u"")
|
2004-11-16 09:14:23 +05:30
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
|
_qual_str = (u"", u"оцен ", u"вычисл ")
|
2006-05-02 02:41:26 +05:30
|
|
|
|
|
|
|
|
|
_bce_str = u"%s до н.э."
|
2005-01-19 05:43:57 +05:30
|
|
|
|
|
|
|
|
|
formats = (
|
2007-06-27 10:20:33 +05:30
|
|
|
|
"ГГГГ-ММ-ДД (ISO)", "Численный", "Месяц День, Год",
|
2005-01-19 05:43:57 +05:30
|
|
|
|
"МЕС ДД, ГГГГГ", "День Месяц, Год", "ДД МЕС, ГГГГГ"
|
|
|
|
|
)
|
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
|
hebrew = ( u"",
|
|
|
|
|
u"Тишрей",
|
|
|
|
|
u"Хешван",
|
|
|
|
|
u"Кислев",
|
|
|
|
|
u"Тевет",
|
|
|
|
|
u"Шеват",
|
|
|
|
|
u"Адар",
|
|
|
|
|
u"Адар бет",
|
|
|
|
|
u"Нисан",
|
|
|
|
|
u"Ияр",
|
|
|
|
|
u"Сиван",
|
|
|
|
|
u"Таммуз",
|
|
|
|
|
u"Ав",
|
|
|
|
|
u"Элул",
|
2006-05-02 02:41:26 +05:30
|
|
|
|
)
|
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
|
islamic = ( u"",
|
|
|
|
|
u"Мухаррам",
|
|
|
|
|
u"Сафар",
|
|
|
|
|
u"Раби-аль-авваль",
|
|
|
|
|
u"Раби-ассани",
|
|
|
|
|
u"Джумада-аль-уля",
|
|
|
|
|
u"Джумада-аль-ахира",
|
|
|
|
|
u"Раджаб",
|
|
|
|
|
u"Шаабан",
|
|
|
|
|
u"Рамадан",
|
|
|
|
|
u"Шавваль",
|
|
|
|
|
u"Зуль-каада",
|
|
|
|
|
u"Зуль-хиджжа",
|
2006-05-02 02:41:26 +05:30
|
|
|
|
)
|
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
|
persian = ( u"",
|
|
|
|
|
u"Фарвардин",
|
|
|
|
|
u"Урдбихишт",
|
|
|
|
|
u"Хурдад",
|
|
|
|
|
u"Тир",
|
|
|
|
|
u"Мурдад",
|
|
|
|
|
u"Шахривар",
|
|
|
|
|
u"Михр",
|
|
|
|
|
u"Абан",
|
|
|
|
|
u"Азар",
|
|
|
|
|
u"Дай",
|
|
|
|
|
u"Бахман",
|
|
|
|
|
u"Исфаидармуз",
|
2006-05-02 02:41:26 +05:30
|
|
|
|
)
|
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
|
french = ( u"",
|
|
|
|
|
u"Вандемьер",
|
|
|
|
|
u"Брюмер",
|
|
|
|
|
u"Фример",
|
|
|
|
|
u"Нивоз",
|
2006-05-02 02:41:26 +05:30
|
|
|
|
u"Плювиоз",
|
2007-06-27 10:20:33 +05:30
|
|
|
|
u"Вантоз",
|
|
|
|
|
u"Жерминаль",
|
|
|
|
|
u"Флореаль",
|
|
|
|
|
u"Прериаль",
|
|
|
|
|
u"Мессидор",
|
|
|
|
|
u"Термидор",
|
|
|
|
|
u"Фрюктидор",
|
2006-05-02 02:41:26 +05:30
|
|
|
|
u"Дополнит."
|
|
|
|
|
)
|
|
|
|
|
|
2007-06-27 10:20:33 +05:30
|
|
|
|
def display(self, date):
|
2004-11-16 09:14:23 +05:30
|
|
|
|
"""
|
2008-02-24 19:25:55 +05:30
|
|
|
|
Return a text string representing the date.
|
2004-11-16 09:14:23 +05:30
|
|
|
|
"""
|
|
|
|
|
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())
|
2007-06-27 10:20:33 +05:30
|
|
|
|
return "%sс %s %s %s%s" % (qual_str, d1, u'по', d2,
|
|
|
|
|
self.calendar[cal])
|
2004-11-16 09:14:23 +05:30
|
|
|
|
elif mod == Date.MOD_RANGE:
|
|
|
|
|
d1 = self.display_cal[cal](start)
|
|
|
|
|
d2 = self.display_cal[cal](date.get_stop_date())
|
2007-06-27 10:20:33 +05:30
|
|
|
|
return "%s%s %s %s %s%s" % (qual_str, u'между', d1, u'и',
|
|
|
|
|
d2, self.calendar[cal])
|
2004-11-16 09:14:23 +05:30
|
|
|
|
else:
|
|
|
|
|
text = self.display_cal[date.get_calendar()](start)
|
2007-06-27 10:20:33 +05:30
|
|
|
|
return "%s%s%s%s" % (qual_str, self._mod_str[mod],
|
|
|
|
|
text, self.calendar[cal])
|
2004-11-16 09:14:23 +05:30
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# Register classes
|
|
|
|
|
#
|
|
|
|
|
#-------------------------------------------------------------------------
|
2008-11-13 14:33:05 +05:30
|
|
|
|
register_datehandler(('ru_RU', 'ru', 'russian', 'Russian'), DateParserRU, DateDisplayRU)
|