6753: add long_days to DateStrings

svn: r23369
This commit is contained in:
Vassilii Khachaturov 2013-10-22 18:37:20 +00:00
parent bfa2402b12
commit a4bc19b887
9 changed files with 37 additions and 15 deletions

View File

@ -94,7 +94,7 @@ except:
# Import utility functions
from ._dateutils import *
from ._grampslocale import (codeset, long_days, short_days, tformat)
from ._grampslocale import (codeset, tformat)
if __name__ == "__main__":
from ._datedisplay import DateDisplay

View File

@ -120,6 +120,7 @@ class DateDisplay(object):
self._display_swedish]
self._mod_str = self._ds.modifiers
self._qual_str = self._ds.qualifiers
self.long_days = self._ds.long_days
if format is None:
self.format = 0

View File

@ -217,9 +217,17 @@ class DateStrings(object):
_("date quality|calculated "),
)
# TODO extend with further strings
# along with the date displayer and parser refactoring
# 6753: localized day names. Eventually should sprout into
# a per-calendar type thing instead.
self.long_days = ("",
_("Sunday"),
_("Monday"),
_("Tuesday"),
_("Wednesday"),
_("Thursday"),
_("Friday"),
_("Saturday"),
)
__doc__ += """
__main__
@ -242,7 +250,8 @@ if __name__ == '__main__':
from ..utils.grampslocale import GrampsLocale
from gramps.gen.const import GRAMPS_LOCALE as glocale
from ._grampslocale import (_deprecated_long_months as old_long,
_deprecated_short_months as old_short)
_deprecated_short_months as old_short,
_deprecated_long_days as old_days)
from ._datedisplay import DateDisplay
import gettext
lang = glocale.lang
@ -344,3 +353,5 @@ if __name__ == '__main__':
"date quality|")
except AttributeError:
pass
print_po_snippet((ds_EN.long_days, old_days, old_days), "")

View File

@ -85,7 +85,7 @@ try:
# not the international convention (ISO 8601) that Monday
# is the first day of the week."
# see http://docs.python.org/library/locale.html
long_days = (
_deprecated_long_days = (
"",
to_uni(locale.nl_langinfo(locale.DAY_1), codeset), # Sunday
to_uni(locale.nl_langinfo(locale.DAY_2), codeset), # Monday
@ -96,7 +96,7 @@ try:
to_uni(locale.nl_langinfo(locale.DAY_7), codeset), # Saturday
)
short_days = (
_deprecated_short_days = (
"",
to_uni(locale.nl_langinfo(locale.ABDAY_1), codeset), # Sunday
to_uni(locale.nl_langinfo(locale.ABDAY_2), codeset), # Monday
@ -156,7 +156,7 @@ except:
# number. tm_wday => range [0,6], Monday is 0
# Note. Only the seventh tuple entry matters. The others are
# just a dummy.
long_days = (
_deprecated_long_days = (
"",
to_uni(time.strftime('%A',(1,1,1,1,1,1,6,1,1)), codeset), # Sunday
to_uni(time.strftime('%A',(1,1,1,1,1,1,0,1,1)), codeset), # Monday
@ -167,7 +167,7 @@ except:
to_uni(time.strftime('%A',(1,1,1,1,1,1,5,1,1)), codeset), # Saturday
)
short_days = (
_deprecated_short_days = (
"",
to_uni(time.strftime('%a',(1,1,1,1,1,1,6,1,1)), codeset), # Sunday
to_uni(time.strftime('%a',(1,1,1,1,1,1,0,1,1)), codeset), # Monday

View File

@ -66,6 +66,7 @@ class DateStringsTest(unittest.TestCase):
self.assertEqual(self.ds.long_months[0], "")
self.assertEqual(self.ds.short_months[0], "")
self.assertEqual(self.ds.alt_long_months[0], "")
self.assertEqual(self.ds.long_days[0], "")
def testCalendarIndex(self):
self.assertEqual(self.ds_EN.calendar[Date.CAL_GREGORIAN], "Gregorian")
@ -76,5 +77,8 @@ class DateStringsTest(unittest.TestCase):
self.assertEqual(self.ds_EN.calendar[Date.CAL_ISLAMIC], "Islamic")
self.assertEqual(self.ds_EN.calendar[Date.CAL_SWEDISH], "Swedish")
def testDayNamesLenIs8(self):
self.assertEqual(len(self.ds.long_days), 8)
if __name__ == "__main__":
unittest.main()

View File

@ -67,6 +67,7 @@ class Report(object):
self._ = locale.translation.gettext
self._get_date = locale.get_date
self._get_type = locale.get_type
self._dd = locale.date_displayer
return locale
def write_report(self):

View File

@ -52,7 +52,7 @@ from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.gen.utils.alive import probably_alive
from gramps.gen.datehandler import displayer as _dd, long_days
from gramps.gen.datehandler import displayer as _dd
from gramps.gen.lib import Date, EventRoleType, EventType, Name, NameType, Person, Surname
from gramps.gen.lib.date import gregorian
@ -182,6 +182,7 @@ class Calendar(Report):
pdaynames = style_sheet.get_paragraph_style("CAL-Daynames")
pnumbers = style_sheet.get_paragraph_style("CAL-Numbers")
ptext1style = style_sheet.get_paragraph_style("CAL-Text1style")
long_days = _dd.long_days
self.doc.start_page()
width = self.doc.get_usable_width()
@ -459,6 +460,7 @@ class CalendarOptions(MenuReportOptions):
add_option("country", country)
start_dow = EnumeratedListOption(_("First day of week"), 1)
long_days = _dd.long_days
for count in range(1, 8):
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())

View File

@ -56,10 +56,12 @@ from gramps.gen.plug.report import utils as ReportUtils
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.gen.utils.alive import probably_alive
from gramps.gen.datehandler import long_days
import gramps.plugins.lib.libholiday as libholiday
# localization for BirthdayOptions only!!
from gramps.gen.datehandler import displayer as _dd
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
return value
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
@ -445,6 +447,7 @@ class BirthdayOptions(MenuReportOptions):
menu.add_option(category_name, "country", country)
start_dow = EnumeratedListOption(_("First day of week"), 1)
long_days = _dd.long_days
for count in range(1, 8):
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())

View File

@ -62,7 +62,7 @@ from gramps.gen.plug.menu import BooleanOption, NumberOption, StringOption, \
DestinationOption, NoteOption
from gramps.gen.utils.config import get_researcher
from gramps.gen.utils.alive import probably_alive
from gramps.gen.datehandler import displayer as _dd, long_days
from gramps.gen.datehandler import displayer as _dd
from gramps.gen.display.name import displayer as _nd
@ -627,7 +627,7 @@ class WebCalReport(Report):
# Note. gen.datehandler has sunday => 1, monday => 2, etc
# We slice out the first empty element.
day_names = long_days
day_names = _dd.long_days # use self._dd.long_days when set_locale is used...
def __get_previous_month_day(year, month, day_col):
@ -1085,7 +1085,7 @@ class WebCalReport(Report):
with self._user.progress(_("Web Calendar Report"),
_('Applying Filter...'),
db.get_number_of_people()) as step:
people = self.filter.apply(db, people, step_progress)
people = self.filter.apply(db, people, step)
with self._user.progress(_("Web Calendar Report"),
_("Reading database..."), len(people)) as step:
@ -1437,7 +1437,7 @@ class WebCalOptions(MenuReportOptions):
# Default selection ????
start_dow = EnumeratedListOption(_("First day of week"), 1)
for count in range(1, 8):
start_dow.add_item(count, long_days[count].capitalize())
start_dow.add_item(count, _dd.long_days[count].capitalize())
start_dow.set_help(_("Select the first day of the week for the calendar"))
menu.add_option(category_name, "start_dow", start_dow)