~gestikk/gestikk/gestikk-0.5

« back to all changes in this revision

Viewing changes to gestikk/tools.py

  • Committer: Friedrich Weber
  • Date: 2008-04-03 12:06:46 UTC
  • Revision ID: fred@reichbier.de-20080403120646-0kaldl3l042avjcd
removed language chooser. If you want it in english, you have to call LC_ALL=C python gestikk.py
I hope that's the last change :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
409
409
    """ Format an Action() human-readable """
410
410
    return _('Gesture %(gesture)s: %(action)s') % {'gesture':action.gesture, 'action':action.get_formatted()}
411
411
 
412
 
def get_language():
413
 
    """ get the preferred language, e.g. de """
414
 
    cp = ConfigParser.ConfigParser() # nicht gerade sauber, aber sonst f�llt mir nichts ein
415
 
    cp.read(CONFIG_FILE)
416
 
    try:
417
 
        if cp.has_section('Preferences') \
418
 
            and cp.has_option('Preferences', 'language') \
419
 
            and cp.get('Preferences', 'language') != '':
420
 
            return cp.get('Preferences', 'language')
421
 
        else:
422
 
            return locale.getdefaultlocale()[0].split('_')[0]
423
 
    finally:
424
 
        del cp
425
 
 
426
412
def init_gettext():
427
413
    """ init gettext """
428
414
    gettext.install('gestikk')
429
415
    gtk.glade.textdomain('gestikk')
430
 
    #lang = gettext.translation('gestikk', '/usr/share/locale', languges=[get_language()], fallback=True)
431
416
    # first in system's defaults
432
417
    try:
433
 
        lang = gettext.translation('gestikk', languages=[get_language()])
 
418
        lang = gettext.translation('gestikk', '/usr/share/locale')
434
419
        gtk.glade.bindtextdomain('gestikk')
435
420
    # then in ./locale/
436
421
    except IOError:
437
 
        lang = gettext.translation('gestikk', os.path.join(BASEDIR, 'locale'), languages=[get_language()], fallback=True)
 
422
        lang = gettext.translation('gestikk', os.path.join(BASEDIR, 'locale'), fallback=True)
438
423
        gtk.glade.bindtextdomain('gestikk', os.path.join(BASEDIR, 'locale'))
439
424
        # otherwise: fallback (english)
440
425
    return lang