6753: add long_days to DateStrings
svn: r23369
This commit is contained in:
parent
bfa2402b12
commit
a4bc19b887
@ -94,7 +94,7 @@ except:
|
|||||||
|
|
||||||
# Import utility functions
|
# Import utility functions
|
||||||
from ._dateutils import *
|
from ._dateutils import *
|
||||||
from ._grampslocale import (codeset, long_days, short_days, tformat)
|
from ._grampslocale import (codeset, tformat)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from ._datedisplay import DateDisplay
|
from ._datedisplay import DateDisplay
|
||||||
|
@ -120,6 +120,7 @@ class DateDisplay(object):
|
|||||||
self._display_swedish]
|
self._display_swedish]
|
||||||
self._mod_str = self._ds.modifiers
|
self._mod_str = self._ds.modifiers
|
||||||
self._qual_str = self._ds.qualifiers
|
self._qual_str = self._ds.qualifiers
|
||||||
|
self.long_days = self._ds.long_days
|
||||||
|
|
||||||
if format is None:
|
if format is None:
|
||||||
self.format = 0
|
self.format = 0
|
||||||
|
@ -217,9 +217,17 @@ class DateStrings(object):
|
|||||||
_("date quality|calculated "),
|
_("date quality|calculated "),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 6753: localized day names. Eventually should sprout into
|
||||||
# TODO extend with further strings
|
# a per-calendar type thing instead.
|
||||||
# along with the date displayer and parser refactoring
|
self.long_days = ("",
|
||||||
|
_("Sunday"),
|
||||||
|
_("Monday"),
|
||||||
|
_("Tuesday"),
|
||||||
|
_("Wednesday"),
|
||||||
|
_("Thursday"),
|
||||||
|
_("Friday"),
|
||||||
|
_("Saturday"),
|
||||||
|
)
|
||||||
|
|
||||||
__doc__ += """
|
__doc__ += """
|
||||||
__main__
|
__main__
|
||||||
@ -242,7 +250,8 @@ if __name__ == '__main__':
|
|||||||
from ..utils.grampslocale import GrampsLocale
|
from ..utils.grampslocale import GrampsLocale
|
||||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||||
from ._grampslocale import (_deprecated_long_months as old_long,
|
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
|
from ._datedisplay import DateDisplay
|
||||||
import gettext
|
import gettext
|
||||||
lang = glocale.lang
|
lang = glocale.lang
|
||||||
@ -344,3 +353,5 @@ if __name__ == '__main__':
|
|||||||
"date quality|")
|
"date quality|")
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
print_po_snippet((ds_EN.long_days, old_days, old_days), "")
|
||||||
|
@ -85,7 +85,7 @@ try:
|
|||||||
# not the international convention (ISO 8601) that Monday
|
# not the international convention (ISO 8601) that Monday
|
||||||
# is the first day of the week."
|
# is the first day of the week."
|
||||||
# see http://docs.python.org/library/locale.html
|
# 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_1), codeset), # Sunday
|
||||||
to_uni(locale.nl_langinfo(locale.DAY_2), codeset), # Monday
|
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
|
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_1), codeset), # Sunday
|
||||||
to_uni(locale.nl_langinfo(locale.ABDAY_2), codeset), # Monday
|
to_uni(locale.nl_langinfo(locale.ABDAY_2), codeset), # Monday
|
||||||
@ -156,7 +156,7 @@ except:
|
|||||||
# number. tm_wday => range [0,6], Monday is 0
|
# number. tm_wday => range [0,6], Monday is 0
|
||||||
# Note. Only the seventh tuple entry matters. The others are
|
# Note. Only the seventh tuple entry matters. The others are
|
||||||
# just a dummy.
|
# 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,6,1,1)), codeset), # Sunday
|
||||||
to_uni(time.strftime('%A',(1,1,1,1,1,1,0,1,1)), codeset), # Monday
|
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
|
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,6,1,1)), codeset), # Sunday
|
||||||
to_uni(time.strftime('%a',(1,1,1,1,1,1,0,1,1)), codeset), # Monday
|
to_uni(time.strftime('%a',(1,1,1,1,1,1,0,1,1)), codeset), # Monday
|
||||||
|
@ -66,6 +66,7 @@ class DateStringsTest(unittest.TestCase):
|
|||||||
self.assertEqual(self.ds.long_months[0], "")
|
self.assertEqual(self.ds.long_months[0], "")
|
||||||
self.assertEqual(self.ds.short_months[0], "")
|
self.assertEqual(self.ds.short_months[0], "")
|
||||||
self.assertEqual(self.ds.alt_long_months[0], "")
|
self.assertEqual(self.ds.alt_long_months[0], "")
|
||||||
|
self.assertEqual(self.ds.long_days[0], "")
|
||||||
|
|
||||||
def testCalendarIndex(self):
|
def testCalendarIndex(self):
|
||||||
self.assertEqual(self.ds_EN.calendar[Date.CAL_GREGORIAN], "Gregorian")
|
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_ISLAMIC], "Islamic")
|
||||||
self.assertEqual(self.ds_EN.calendar[Date.CAL_SWEDISH], "Swedish")
|
self.assertEqual(self.ds_EN.calendar[Date.CAL_SWEDISH], "Swedish")
|
||||||
|
|
||||||
|
def testDayNamesLenIs8(self):
|
||||||
|
self.assertEqual(len(self.ds.long_days), 8)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -67,6 +67,7 @@ class Report(object):
|
|||||||
self._ = locale.translation.gettext
|
self._ = locale.translation.gettext
|
||||||
self._get_date = locale.get_date
|
self._get_date = locale.get_date
|
||||||
self._get_type = locale.get_type
|
self._get_type = locale.get_type
|
||||||
|
self._dd = locale.date_displayer
|
||||||
return locale
|
return locale
|
||||||
|
|
||||||
def write_report(self):
|
def write_report(self):
|
||||||
|
@ -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 MenuReportOptions
|
||||||
from gramps.gen.plug.report import stdoptions
|
from gramps.gen.plug.report import stdoptions
|
||||||
from gramps.gen.utils.alive import probably_alive
|
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 import Date, EventRoleType, EventType, Name, NameType, Person, Surname
|
||||||
from gramps.gen.lib.date import gregorian
|
from gramps.gen.lib.date import gregorian
|
||||||
|
|
||||||
@ -182,6 +182,7 @@ class Calendar(Report):
|
|||||||
pdaynames = style_sheet.get_paragraph_style("CAL-Daynames")
|
pdaynames = style_sheet.get_paragraph_style("CAL-Daynames")
|
||||||
pnumbers = style_sheet.get_paragraph_style("CAL-Numbers")
|
pnumbers = style_sheet.get_paragraph_style("CAL-Numbers")
|
||||||
ptext1style = style_sheet.get_paragraph_style("CAL-Text1style")
|
ptext1style = style_sheet.get_paragraph_style("CAL-Text1style")
|
||||||
|
long_days = _dd.long_days
|
||||||
|
|
||||||
self.doc.start_page()
|
self.doc.start_page()
|
||||||
width = self.doc.get_usable_width()
|
width = self.doc.get_usable_width()
|
||||||
@ -459,6 +460,7 @@ class CalendarOptions(MenuReportOptions):
|
|||||||
add_option("country", country)
|
add_option("country", country)
|
||||||
|
|
||||||
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
||||||
|
long_days = _dd.long_days
|
||||||
for count in range(1, 8):
|
for count in range(1, 8):
|
||||||
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
|
# 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())
|
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())
|
||||||
|
@ -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 MenuReportOptions
|
||||||
from gramps.gen.plug.report import stdoptions
|
from gramps.gen.plug.report import stdoptions
|
||||||
from gramps.gen.utils.alive import probably_alive
|
from gramps.gen.utils.alive import probably_alive
|
||||||
from gramps.gen.datehandler import long_days
|
|
||||||
|
|
||||||
import gramps.plugins.lib.libholiday as libholiday
|
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)
|
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
|
||||||
return value
|
return value
|
||||||
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
|
# _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)
|
menu.add_option(category_name, "country", country)
|
||||||
|
|
||||||
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
||||||
|
long_days = _dd.long_days
|
||||||
for count in range(1, 8):
|
for count in range(1, 8):
|
||||||
# conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below
|
# 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())
|
start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize())
|
||||||
|
@ -62,7 +62,7 @@ from gramps.gen.plug.menu import BooleanOption, NumberOption, StringOption, \
|
|||||||
DestinationOption, NoteOption
|
DestinationOption, NoteOption
|
||||||
from gramps.gen.utils.config import get_researcher
|
from gramps.gen.utils.config import get_researcher
|
||||||
from gramps.gen.utils.alive import probably_alive
|
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
|
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
|
# Note. gen.datehandler has sunday => 1, monday => 2, etc
|
||||||
# We slice out the first empty element.
|
# 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):
|
def __get_previous_month_day(year, month, day_col):
|
||||||
|
|
||||||
@ -1085,7 +1085,7 @@ class WebCalReport(Report):
|
|||||||
with self._user.progress(_("Web Calendar Report"),
|
with self._user.progress(_("Web Calendar Report"),
|
||||||
_('Applying Filter...'),
|
_('Applying Filter...'),
|
||||||
db.get_number_of_people()) as step:
|
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"),
|
with self._user.progress(_("Web Calendar Report"),
|
||||||
_("Reading database..."), len(people)) as step:
|
_("Reading database..."), len(people)) as step:
|
||||||
@ -1437,7 +1437,7 @@ class WebCalOptions(MenuReportOptions):
|
|||||||
# Default selection ????
|
# Default selection ????
|
||||||
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
start_dow = EnumeratedListOption(_("First day of week"), 1)
|
||||||
for count in range(1, 8):
|
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"))
|
start_dow.set_help(_("Select the first day of the week for the calendar"))
|
||||||
menu.add_option(category_name, "start_dow", start_dow)
|
menu.add_option(category_name, "start_dow", start_dow)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user