unsupported locale error is skipped and

we use en for wiki search (better to search
in english wikipedia than not having gajim at
all)
This commit is contained in:
Dimitur Kirov 2006-04-22 08:53:01 +00:00
parent 6d784bbe53
commit 029668bf20
2 changed files with 10 additions and 2 deletions

View File

@ -23,6 +23,7 @@ import base64
import sha import sha
import socket import socket
import sys import sys
import locale
from calendar import timegm from calendar import timegm
@ -1232,7 +1233,9 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
mtype = msg.getType() mtype = msg.getType()
subject = msg.getSubject() # if not there, it's None subject = msg.getSubject() # if not there, it's None
tim = msg.getTimestamp() tim = msg.getTimestamp()
locale.setlocale(locale.LC_TIME, 'C')
tim = time.strptime(tim, '%Y%m%dT%H:%M:%S') tim = time.strptime(tim, '%Y%m%dT%H:%M:%S')
locale.setlocale(locale.LC_TIME, '')
tim = time.localtime(timegm(tim)) tim = time.localtime(timegm(tim))
frm = helpers.get_full_jid_from_iq(msg) frm = helpers.get_full_jid_from_iq(msg)
jid = helpers.get_jid_from_iq(msg) jid = helpers.get_jid_from_iq(msg)
@ -1361,7 +1364,9 @@ class ConnectionHandlers(ConnectionVcard, ConnectionBytestream, ConnectionDisco)
if x.getNamespace() == common.xmpp.NS_DELAY: if x.getNamespace() == common.xmpp.NS_DELAY:
# JEP-0091 # JEP-0091
tim = prs.getTimestamp() tim = prs.getTimestamp()
locale.setlocale(locale.LC_TIME, 'C')
tim = time.strptime(tim, '%Y%m%dT%H:%M:%S') tim = time.strptime(tim, '%Y%m%dT%H:%M:%S')
locale.setlocale(locale.LC_TIME, '')
timestamp = time.localtime(timegm(tim)) timestamp = time.localtime(timegm(tim))
if x.getNamespace() == 'http://delx.cjb.net/protocol/roster-subsync': if x.getNamespace() == 'http://delx.cjb.net/protocol/roster-subsync':
# see http://trac.gajim.org/ticket/326 # see http://trac.gajim.org/ticket/326

View File

@ -71,8 +71,11 @@ try:
MY_EMOTS_PATH = MY_EMOTS_PATH.decode(sys.getfilesystemencoding()) MY_EMOTS_PATH = MY_EMOTS_PATH.decode(sys.getfilesystemencoding())
except: except:
pass pass
try:
LANG = locale.getdefaultlocale()[0] # en_US, fr_FR, el_GR etc.. LANG = locale.getdefaultlocale()[0] # en_US, fr_FR, el_GR etc..
except (ValueError, locale.Error):
# unknown locale, use en is better than fail
LANG = None
if LANG is None: if LANG is None:
LANG = 'en' LANG = 'en'
else: else: