idlesign/deluge-updatorr — Issue #3: Windows client: Gibberish symbols instead of month name on statusbar.
Author: dredkin
Created: 2012-02-21 23:26:51+00:00
State: open

As I've mentioned in issue#1, there are problems with showng localized dates on status bar.
I've made some research and found that (at least on windows systems) strftime returns dates encoded in default system encoding (which is cp1251 on my system).
No surprise it is not recognized as utf-8.
I could workaround this issue with the following code [gtkui.py]:

diff --git a/updatorr/gtkui.py b/updatorr/gtkui.py
index 0c4453e..397df90 100644
--- a/updatorr/gtkui.py
+++ b/updatorr/gtkui.py
@@ -2,6 +2,7 @@ import os
import logging
import pkg_resources
from datetime import datetime
+import locale

import gtk
import deluge.component as component
@@ -111,6 +112,9 @@ class GtkUI(GtkPluginBase):
"""Returns autoupdate status and puts it our status bar item."""
last_updated = datetime.fromtimestamp(status_data[0]).strftime(self.DATE_FORMAT)
next_update = datetime.fromtimestamp(status_data[0] + (status_data[1] * 3600)).strftime(self.DATE_FORMAT)
+ if os.name == 'nt':
+ last_updated = last_updated.decode(locale.getdefaultlocale()[1]).encode('utf8')
+ next_update = next_update.decode(locale.getdefaultlocale()[1]).encode('utf8')
self.status_bar_item.set_text(_('last: %s, next: %s') % (last_updated, next_update))

def disable(self):

Now month names are shown ok on status bar.
I don't know how strftime works on linux: does it return strings encoded according to encoding of system locale or strictly unicode. If it's the former, you could remove platform check.