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 |
36 | 36 | from gettext import gettext as _ |
37 | 37 | import math |
38 | 38 | import time |
| 39 | import locale |
39 | 40 | import os |
40 | 41 | |
41 | 42 | try: |
… |
… |
class MoonActivity(activity.Activity): |
261 | 262 | 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} |
262 | 263 | information_string += _("Surface Visibility:\n%.0f%% (estimated)\n\n") % (self.data_model.percent_of_full_moon * 100) |
263 | 264 | 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} |
268 | 269 | self.info.set_markup(information_string) |
269 | 270 | |
270 | 271 | # Calculate time to next minute cusp and set a new timer |