Ticket #2538: 0001-using-nl_langinfo-to-localize-date-time-strings.patch

File 0001-using-nl_langinfo-to-localize-date-time-strings.patch, 3.0 KB (added by walter, 10 years ago)

patch to add locale info to date/time strings

  • moon.py

    From 54c9f59f5d9031eaa5289869e1de035ea15f280d Mon Sep 17 00:00:00 2001
    From: Walter Bender <walter@walter-thinker.(none)>
    Date: Tue, 21 Dec 2010 10:00:52 -0500
    Subject: [PATCH] using nl_langinfo to localize date/time strings
    
    ---
     moon.py |    9 +++++----
     1 files changed, 5 insertions(+), 4 deletions(-)
    
    diff --git a/moon.py b/moon.py
    index e730411..fb5937e 100755
    a b from sugar.graphics.toolbutton import ToolButton 
    3636from gettext import gettext as _
    3737import math
    3838import time
     39import locale
    3940import os
    4041
    4142try:
    class MoonActivity(activity.Activity): 
    261262        information_string += _("Lunation:\n%(phase).2f%% through lunation %(lunation)d\n\n") % {'phase':self.data_model.phase_of_moon * 100, 'lunation':self.data_model.lunation}
    262263        information_string += _("Surface Visibility:\n%.0f%% (estimated)\n\n") % (self.data_model.percent_of_full_moon * 100)
    263264        information_string += _(u"Selenographic Terminator Longitude:\n%(deg).1f\u00b0%(westOrEast)s (%(riseOrSet)s)\n\n") % {'deg':self.data_model.selenographic_deg, 'westOrEast':self.data_model.west_or_east, 'riseOrSet':self.data_model.rise_or_set}
    264         information_string += _("Next Full Moon:\n%(date)s in %(days).0f days\n\n") % {'date':time.ctime(self.data_model.next_full_moon_date), 'days':self.data_model.days_until_full_moon}
    265         information_string += _("Next New Moon:\n%(date)s in %(days).0f days\n\n") % {'date':time.ctime(self.data_model.next_new_moon_date), 'days':self.data_model.days_until_new_moon}
    266         information_string += _("Next Lunar eclipse:\n%(date)s in %(days).0f days\n\n") % {'date':time.ctime(self.data_model.next_lunar_eclipse_date), 'days':self.data_model.days_until_lunar_eclipse}
    267         information_string += _("Next Solar eclipse:\n%(date)s in %(days).0f days\n\n") % {'date':time.ctime(self.data_model.next_solar_eclipse_date), 'days':self.data_model.days_until_solar_eclipse}
     265        information_string += _("Next Full Moon:\n%(date)s in %(days).0f days\n\n") % {'date':time.strftime(locale.nl_langinfo(locale.D_T_FMT),time.localtime(self.data_model.next_full_moon_date)), 'days':self.data_model.days_until_full_moon}
     266        information_string += _("Next New Moon:\n%(date)s in %(days).0f days\n\n") % {'date':time.strftime(locale.nl_langinfo(locale.D_T_FMT),time.localtime(self.data_model.next_new_moon_date)), 'days':self.data_model.days_until_new_moon}
     267        information_string += _("Next Lunar eclipse:\n%(date)s in %(days).0f days\n\n") % {'date':time.strftime(locale.nl_langinfo(locale.D_T_FMT),time.localtime(self.data_model.next_lunar_eclipse_date)), 'days':self.data_model.days_until_lunar_eclipse}
     268        information_string += _("Next Solar eclipse:\n%(date)s in %(days).0f days\n\n") % {'date':time.strftime(locale.nl_langinfo(locale.D_T_FMT),time.localtime(self.data_model.next_solar_eclipse_date)), 'days':self.data_model.days_until_solar_eclipse}
    268269        self.info.set_markup(information_string)
    269270
    270271        # Calculate time to next minute cusp and set a new timer