* src/Calendar.py: removed
* src/Gregorian.py: removed * src/Hebrew.py: removed * src/Julian.py: removed * src/calendars/Islamic.py: removed * src/calendars/Persian.py: removed * src/calendars/Makefile.am: removed * src/Date.py: New, simpler date structure * src/DateHandler.py: Start of a class to abstract and select parser and display functions based off locale * src/DateParser.py: base date parsing class (US English) * src/DateDisplay.py: base date display class (US English) * src/DateEdit.py: handle new date method * src/EditPerson.py: handle new date method * src/EventEdit.py: handle new date method * src/GrampsCfg.py: removed redundant options due to new date class * src/StartupDialog.py: removed redundant options due to new date class * src/Makefile.am: handle file changes * src/Sort.py: handle new date method * src/ReadGedcom.py: handle new date method * src/ReadXML.py: handle new date method * src/WriteGedcom.py: handle new date method * src/WriteXML.py: handle new date method * src/RelLib.py: handle new date method * src/gramps_main.py: handle new date method * src/gramps.glade: handle new date method svn: r3546
This commit is contained in:
60
src/DateHandler.py
Normal file
60
src/DateHandler.py
Normal file
@@ -0,0 +1,60 @@
|
||||
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,
|
||||
'en.US' : DateParser.DateParser,
|
||||
}
|
||||
|
||||
_lang_to_display = {
|
||||
'C' : DateDisplay.DateDisplay,
|
||||
'en.US' : DateDisplay.DateDisplay,
|
||||
}
|
||||
|
||||
def create_parser():
|
||||
try:
|
||||
return _lang_to_parser[_lang]()
|
||||
except:
|
||||
print "not found"
|
||||
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:
|
||||
print "not found"
|
||||
pass
|
||||
|
||||
def get_format():
|
||||
try:
|
||||
return _lang_to_display[_lang].display_format
|
||||
except:
|
||||
print "not found"
|
||||
return 0
|
Reference in New Issue
Block a user