2004-09-17 09:00:04 +05:30
|
|
|
import DateParser
|
|
|
|
import DateDisplay
|
|
|
|
import os
|
|
|
|
|
|
|
|
try:
|
|
|
|
import gconf
|
|
|
|
except ImportError:
|
|
|
|
import gnome.gconf
|
|
|
|
gconf = gnome.gconf
|
|
|
|
|
|
|
|
client = gconf.client_get_default()
|
|
|
|
client.add_dir("/apps/gramps",gconf.CLIENT_PRELOAD_NONE)
|
|
|
|
|
|
|
|
_lang = os.environ.get('LANG','C')
|
|
|
|
|
|
|
|
|
|
|
|
_lang_to_parser = {
|
|
|
|
'C' : DateParser.DateParser,
|
2004-09-25 03:35:46 +05:30
|
|
|
'en_US' : DateParser.DateParser,
|
2004-09-17 09:00:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
_lang_to_display = {
|
|
|
|
'C' : DateDisplay.DateDisplay,
|
2004-09-25 03:35:46 +05:30
|
|
|
'en_US' : DateDisplay.DateDisplay,
|
2004-09-17 09:00:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
def create_parser():
|
|
|
|
try:
|
|
|
|
return _lang_to_parser[_lang]()
|
|
|
|
except:
|
|
|
|
return DateParser.DateParser()
|
|
|
|
|
|
|
|
def create_display():
|
|
|
|
val = client.get_int("/apps/gramps/preferences/date-format")
|
|
|
|
try:
|
|
|
|
return _lang_to_display[_lang](val)
|
|
|
|
except:
|
|
|
|
return DateDisplay.DateDisplay(3)
|
|
|
|
|
|
|
|
def get_date_formats():
|
|
|
|
try:
|
|
|
|
return _lang_to_display[_lang].formats
|
|
|
|
except:
|
|
|
|
print "not found"
|
|
|
|
return DateDisplay.DateDisplay.formats
|
|
|
|
|
|
|
|
def set_format(val):
|
|
|
|
try:
|
|
|
|
_lang_to_display[_lang].display_format = val
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_format():
|
|
|
|
try:
|
|
|
|
return _lang_to_display[_lang].display_format
|
|
|
|
except:
|
|
|
|
print "not found"
|
|
|
|
return 0
|