[gnome-clocks] Localize "repeat" strings



commit 4e7671b2393f6d2b7cfc96d336022921355ab1a6
Author: Paolo Borelli <pborelli gnome org>
Date:   Thu Aug 30 21:42:51 2012 +0200

    Localize "repeat" strings

 gnomeclocks/alarm.py |   28 ++++++++++++++--------------
 gnomeclocks/utils.py |   11 +++++++++++
 2 files changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index 3a82613..532a552 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -23,7 +23,7 @@ from datetime import datetime, timedelta
 from gi.repository import GLib, GObject, Gio, Gtk, GdkPixbuf
 from gi.repository import GWeather
 from clocks import Clock
-from utils import Dirs, SystemSettings, Alert
+from utils import Dirs, SystemSettings, LocalizedWeekdays, Alert
 from widgets import DigitalClockDrawing, SelectableIconView, ContentView
 
 
@@ -100,7 +100,7 @@ class AlarmItem:
         if vevent.rrule.value == 'FREQ=DAILY;':
             self.repeat = ['FR', 'MO', 'SA', 'SU', 'TH', 'TU', 'WE']
         else:
-            self.repeat = vevent.rrule.value[19:].split(',')
+            self.repeat = [d.upper() for d in vevent.rrule.value[18:].split(',')]
         self.expired = datetime.now() > self.time
 
     def get_time_as_string(self):
@@ -127,28 +127,28 @@ class AlarmItem:
         # sorted(list of days)
         sorted_repeat = sorted(self.repeat)
         if sorted_repeat == ['FR', 'MO', 'SA', 'SU', 'TH', 'TU', 'WE']:
-            return "Every day"
+            return _("Every day")
         elif sorted_repeat == ['FR', 'MO', 'TH', 'TU', 'WE']:
-            return "Weekdays"
+            return _("Weekdays")
         elif len(sorted_repeat) == 0:
-            return None
+            return ""
         else:
-            repeat_string = ""
+            days = []
             if 'MO' in self.repeat:
-                repeat_string += 'Mon, '
+                days.append(LocalizedWeekdays.MO)
             if 'TU' in self.repeat:
-                repeat_string += 'Tue, '
+                days.append(LocalizedWeekdays.TU)
             if 'WE' in self.repeat:
-                repeat_string += 'Wed, '
+                days.append(LocalizedWeekdays.WE)
             if 'TH' in self.repeat:
-                repeat_string += 'Thu, '
+                days.append(LocalizedWeekdays.TH)
             if 'FR' in self.repeat:
-                repeat_string += 'Fri, '
+                days.append(LocalizedWeekdays.FR)
             if 'SA' in self.repeat:
-                repeat_string += 'Sat, '
+                days.append(LocalizedWeekdays.SA)
             if 'SU' in self.repeat:
-                repeat_string += 'Sun, '
-            return repeat_string[:-2]
+                days.append(LocalizedWeekdays.SU)
+            return ", ".join(days)
 
     def get_vevent(self):
         if self.vevent:
diff --git a/gnomeclocks/utils.py b/gnomeclocks/utils.py
index 6f85a27..03da9b7 100644
--- a/gnomeclocks/utils.py
+++ b/gnomeclocks/utils.py
@@ -17,6 +17,7 @@
 # Author: Seif Lotfy <seif lotfy collabora co uk>
 
 import os
+import time
 import pycanberra
 from xdg import BaseDirectory
 from gi.repository import Gio, Notify
@@ -60,6 +61,16 @@ class SystemSettings:
         return systemClockFormat
 
 
+class LocalizedWeekdays:
+    MO = time.strftime("%a", (0, 0, 0, 0, 0, 0, 0, 0, 0))
+    TU = time.strftime("%a", (0, 0, 0, 0, 0, 0, 1, 0, 0))
+    WE = time.strftime("%a", (0, 0, 0, 0, 0, 0, 2, 0, 0))
+    TH = time.strftime("%a", (0, 0, 0, 0, 0, 0, 3, 0, 0))
+    FR = time.strftime("%a", (0, 0, 0, 0, 0, 0, 4, 0, 0))
+    SA = time.strftime("%a", (0, 0, 0, 0, 0, 0, 5, 0, 0))
+    SU = time.strftime("%a", (0, 0, 0, 0, 0, 0, 6, 0, 0))
+
+
 class Alert:
     def __init__(self, soundid, msg, callback):
         try:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]