~ubuntu-branches/ubuntu/precise/monajat/precise

« back to all changes in this revision

Viewing changes to monajat/applet.py

  • Committer: Package Import Robot
  • Author(s): أحمد المحمودي (Ahmed El-Mahmoudy)
  • Date: 2011-11-26 23:49:32 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20111126234932-cvlnm43d1o1zydkc
Tags: 2.6.3-1
* New upstream release.
* Remove drop_cmp_to_key.diff as it is included in new upstream release.
* Updated fix_locale.diff to set language after several trials
* debian/control: Set monajat transitional package to be of priority extra
  and in the oldlibs section

Show diffs side-by-side

added added

removed removed

Lines of Context:
241
241
    return gtk.Dialog.run(self, *a, **kw)
242
242
 
243
243
class applet(object):
 
244
  locale_re=re.compile('^[a-z]+_[A-Z]+$', re.I)
244
245
  skip_auto_fn=os.path.expanduser('~/.monajat-applet-skip-auto')
 
246
  
 
247
  def _init_locale(self, lang):
 
248
    try: l=locale.setlocale(locale.LC_MESSAGES, (lang, 'UTF-8'))
 
249
    except: pass
 
250
    else:
 
251
      if l: os.environ['LC_MESSAGES']=l
 
252
      return
 
253
    for l in locale.locale_alias.keys():
 
254
      if not l.startswith(lang+'_') or not self.locale_re.match(l): continue
 
255
      l,c=l.split('_',1)
 
256
      l=l+"_"+c.upper()+".UTF-8"
 
257
      try: locale.setlocale(locale.LC_MESSAGES, l)
 
258
      except locale.Error: pass
 
259
      else:
 
260
          os.environ['LC_MESSAGES']=l
 
261
          return
 
262
 
245
263
  def __init__(self):
246
264
    self.conf_dlg=None
247
265
    self.chngbody=time.time()
252
270
    self.prayer_items=[]
253
271
    kw=self.conf_to_prayer_args()
254
272
    self.prayer=itl.PrayerTimes(**kw)
255
 
    try:
256
 
      l=locale.setlocale(locale.LC_MESSAGES, (self.m.lang, 'UTF-8'))
257
 
      if l: os.environ['LC_MESSAGES']=l
258
 
    except locale.Error: pass
 
273
    self._init_locale(self.m.lang)
259
274
    ld=os.path.join(self.m.get_prefix(),'..','locale')
260
275
    gettext.install('monajat', ld, unicode=0)
261
276
    self.ptnames=[_("Fajr"), _("Sunrise"), _("Dhuhr"), _("Asr"), _("Maghrib"), _("Isha'a")]
328
343
    if "alt" not in kw or not kw["alt"]: kw["alt"]=0.0
329
344
    kw["tz"]=kw["utc"]
330
345
    # NOTE: get DST from machine local setting
331
 
    kw["dst"]=time.daylight
 
346
    kw["dst"]=time.localtime().tm_isdst
332
347
    # FIXME: dst should have the following 3 options
333
348
    # a. auto from system, b. auto from algorithm, c. specified to 0/1 by user
334
349
    #dst=kw["dst_id"]