* src/DateDisplay.py: use LC_TIME and D_FMT to determine
the locale date format * src/DateHandler.py: en.US to en_US * src/ReadGedcom.py: Allow user overriding of character set * src/StartupDialog.py: remove date entry setting * src/gedcomimport.glade: Allow user overriding of character set * src/gramps.py: set LC_TIME based of LANG * src/data/gramps.schemas: remove date entry setting * src/DateDisplay.py: use unicode encodings for french months svn: r3571
This commit is contained in:
parent
42973b70e3
commit
f61ab522d9
@ -1,7 +1,17 @@
|
||||
2004-09-24 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/DateDisplay.py: use LC_TIME and D_FMT to determine
|
||||
the locale date format
|
||||
* src/DateHandler.py: en.US to en_US
|
||||
* src/ReadGedcom.py: Allow user overriding of character set
|
||||
* src/StartupDialog.py: remove date entry setting
|
||||
* src/gedcomimport.glade: Allow user overriding of character set
|
||||
* src/gramps.py: set LC_TIME based of LANG
|
||||
* src/data/gramps.schemas: remove date entry setting
|
||||
|
||||
2004-09-23 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/Date.py: display calendar
|
||||
* src/DateParser.py: parse based on calendars
|
||||
* src/DateDisplay.py: use unicode encodings for french monts
|
||||
* src/DateDisplay.py: use unicode encodings for french months
|
||||
|
||||
2004-09-22 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/EditPerson.py: change sort mechanism to new Date sort value
|
||||
|
@ -30,6 +30,7 @@ __version__ = "$Revision$"
|
||||
|
||||
import Date
|
||||
import locale
|
||||
import time
|
||||
|
||||
class DateDisplay:
|
||||
"""
|
||||
@ -37,7 +38,7 @@ class DateDisplay:
|
||||
"""
|
||||
|
||||
formats = (
|
||||
"YYYY-MM-DD", "MM/DD/YYYY", "Month Day, Year",
|
||||
"YYYY-MM-DD (ISO)", "Numerical", "Month Day, Year",
|
||||
"MON DAY, YEAR", "Day Month Year", "DAY MON YEAR"
|
||||
)
|
||||
|
||||
@ -88,6 +89,8 @@ class DateDisplay:
|
||||
unicode(locale.nl_langinfo(locale.ABMON_11),_codeset),
|
||||
unicode(locale.nl_langinfo(locale.ABMON_12),_codeset),
|
||||
)
|
||||
|
||||
_tformat = locale.nl_langinfo(locale.D_FMT)
|
||||
|
||||
_hebrew = (
|
||||
"", "Tishri", "Heshvan", "Kislev", "Tevet", "Shevat",
|
||||
@ -127,7 +130,7 @@ class DateDisplay:
|
||||
self.format = 0
|
||||
else:
|
||||
self.format = format
|
||||
|
||||
|
||||
self.display_cal = [
|
||||
self._display_gregorian,
|
||||
self._display_julian,
|
||||
@ -204,14 +207,11 @@ class DateDisplay:
|
||||
else:
|
||||
return "%s-%d-%d" % (year,date_val[1],date_val[0])
|
||||
elif self.format == 1:
|
||||
# MM/DD/YYYY (American numericalO)
|
||||
if date_val[0] == 0:
|
||||
if date_val[1] == 0:
|
||||
return "%d" % date_val[2]
|
||||
else:
|
||||
return "%d/%d" % (date_val[1],date_val[2])
|
||||
if date_val[0] == 0 and date_val[1] == 0:
|
||||
return str(date_val[2])
|
||||
else:
|
||||
return "%d/%d/%d" % (date_val[1],date_val[0],date_val[2])
|
||||
return time.strftime(self._tformat,(date_val[2],date_val[1],
|
||||
date_val[0],0,0,0,0,0,0))
|
||||
elif self.format == 2:
|
||||
# Month Day, Year
|
||||
if date_val[0] == 0:
|
||||
|
@ -16,12 +16,12 @@ _lang = os.environ.get('LANG','C')
|
||||
|
||||
_lang_to_parser = {
|
||||
'C' : DateParser.DateParser,
|
||||
'en.US' : DateParser.DateParser,
|
||||
'en_US' : DateParser.DateParser,
|
||||
}
|
||||
|
||||
_lang_to_display = {
|
||||
'C' : DateDisplay.DateDisplay,
|
||||
'en.US' : DateDisplay.DateDisplay,
|
||||
'en_US' : DateDisplay.DateDisplay,
|
||||
}
|
||||
|
||||
def create_parser():
|
||||
@ -48,7 +48,6 @@ def set_format(val):
|
||||
try:
|
||||
_lang_to_display[_lang].display_format = val
|
||||
except:
|
||||
print "not found"
|
||||
pass
|
||||
|
||||
def get_format():
|
||||
|
@ -125,6 +125,33 @@ def importData(database, filename, cb=None):
|
||||
|
||||
global callback
|
||||
|
||||
f = open(filename,"r")
|
||||
|
||||
ansel = False
|
||||
gramps = False
|
||||
for index in range(0,50):
|
||||
line = f.readline().split()
|
||||
if line[1] == 'CHAR' and line[2] == "ANSEL":
|
||||
ansel = True
|
||||
if line[1] == 'SOUR' and line[2] == "GRAMPS":
|
||||
gramps = True
|
||||
f.close()
|
||||
|
||||
if not gramps and ansel:
|
||||
glade_file = "%s/gedcomimport.glade" % os.path.dirname(__file__)
|
||||
top = gtk.glade.XML(glade_file,'encoding','gramps')
|
||||
code = top.get_widget('codeset')
|
||||
code.set_active(0)
|
||||
dialog = top.get_widget('encoding')
|
||||
dialog.run()
|
||||
codeset = code.get_active()
|
||||
dialog.destroy()
|
||||
else:
|
||||
codeset = None
|
||||
import2(database, filename, cb, codeset)
|
||||
|
||||
|
||||
def import2(database, filename, cb, codeset):
|
||||
# add some checking here
|
||||
|
||||
glade_file = "%s/gedcomimport.glade" % os.path.dirname(__file__)
|
||||
@ -143,7 +170,7 @@ def importData(database, filename, cb=None):
|
||||
})
|
||||
|
||||
try:
|
||||
g = GedcomParser(database,filename,statusTop)
|
||||
g = GedcomParser(database,filename,statusTop, codeset)
|
||||
except IOError,msg:
|
||||
Utils.destroy_passed_object(statusWindow)
|
||||
ErrorDialog(_("%s could not be opened\n") % filename,str(msg))
|
||||
@ -202,7 +229,7 @@ class GedcomParser:
|
||||
SyntaxError = "Syntax Error"
|
||||
BadFile = "Not a GEDCOM file"
|
||||
|
||||
def __init__(self, dbase, file, window):
|
||||
def __init__(self, dbase, file, window, codeset):
|
||||
self.dp = DateParser.DateParser()
|
||||
self.db = dbase
|
||||
self.person = None
|
||||
@ -230,7 +257,17 @@ class GedcomParser:
|
||||
self.filename = file
|
||||
self.index = 0
|
||||
self.backoff = 0
|
||||
self.cnv = nocnv
|
||||
self.override = codeset != None
|
||||
|
||||
if self.override:
|
||||
if self.override == 0:
|
||||
self.cnv = ansel_to_utf8
|
||||
elif self.override == 1:
|
||||
self.cnv = latin_utf8.latin_to_utf8
|
||||
else:
|
||||
self.cnv = nocnv
|
||||
else:
|
||||
self.cnv = nocnv
|
||||
|
||||
self.geddir = os.path.dirname(os.path.normpath(os.path.abspath(file)))
|
||||
|
||||
@ -1554,7 +1591,7 @@ class GedcomParser:
|
||||
if genby == "GRAMPS":
|
||||
self.gedsource = self.gedmap.get_from_source_tag(matches[2])
|
||||
self.broken_conc = self.gedsource.get_conc()
|
||||
elif matches[1] == "CHAR":
|
||||
elif matches[1] == "CHAR" and not self.override:
|
||||
if matches[2] == "UNICODE" or matches[2] == "UTF-8" or matches[2] == "UTF8":
|
||||
self.cnv = nocnv
|
||||
elif matches[2] == "ANSEL":
|
||||
@ -1564,6 +1601,8 @@ class GedcomParser:
|
||||
self.ignore_sub_junk(2)
|
||||
if self.window:
|
||||
self.update(self.encoding_obj,matches[2])
|
||||
else:
|
||||
self.update(self.encoding_obj,_("Overridden"))
|
||||
elif matches[1] == "GEDC":
|
||||
self.ignore_sub_junk(2)
|
||||
elif matches[1] == "_SCHEMA":
|
||||
|
@ -52,8 +52,6 @@ class StartupDialog:
|
||||
self.w.add(d)
|
||||
d.add(self.build_page1())
|
||||
d.add(self.build_page2())
|
||||
d.add(self.build_page3())
|
||||
d.add(self.build_page4())
|
||||
d.add(self.build_page5())
|
||||
d.add(self.build_page_last())
|
||||
|
||||
@ -106,14 +104,6 @@ class StartupDialog:
|
||||
GrampsCfg.save_researcher_phone(unicode(self.phone.get_text()))
|
||||
GrampsCfg.save_researcher_email(unicode(self.email.get_text()))
|
||||
|
||||
if self.date1.get_active():
|
||||
GrampsCfg.save_date_entry(0)
|
||||
elif self.date2.get_active():
|
||||
GrampsCfg.save_date_entry(1)
|
||||
elif self.date3.get_active():
|
||||
GrampsCfg.save_date_entry(2)
|
||||
|
||||
GrampsCfg.save_calendar(self.calendar.get_active())
|
||||
GrampsCfg.save_uselds(self.lds.get_active())
|
||||
GrampsCfg.save_startup(const.startup)
|
||||
self.w.destroy()
|
||||
@ -174,72 +164,6 @@ class StartupDialog:
|
||||
|
||||
return p
|
||||
|
||||
def build_page3(self):
|
||||
p = gnome.ui.DruidPageStandard()
|
||||
p.set_title(_('Numerical date formats'))
|
||||
p.set_title_foreground(self.fg_color)
|
||||
p.set_background(self.bg_color)
|
||||
p.set_logo(self.logo)
|
||||
|
||||
box = gtk.VBox()
|
||||
box.set_spacing(12)
|
||||
p.append_item("",box,"")
|
||||
|
||||
label = gtk.Label(_('There are three common formats for entering dates in a numerical\n'
|
||||
'format. Without some type of indication, GRAMPS cannot correctly\n'
|
||||
'tell what format you are using. Please indicate your preferred format\n'
|
||||
'for entering numerical dates.'))
|
||||
box.add(label)
|
||||
align = gtk.Alignment(0.5,0)
|
||||
box.add(align)
|
||||
vbox = gtk.VBox()
|
||||
vbox.set_spacing(6)
|
||||
align.add(vbox)
|
||||
|
||||
self.date1 = gtk.RadioButton(label=_("MM/DD/YYYY (United States)"))
|
||||
self.date2 = gtk.RadioButton(label=_("DD/MM/YYYY (European)"),group=self.date1)
|
||||
self.date3 = gtk.RadioButton(label=_("YYYY-MM-DD (ISO)"),group=self.date1)
|
||||
|
||||
val = GrampsCfg.get_date_entry()
|
||||
|
||||
if val == 0:
|
||||
self.date1.set_active(1)
|
||||
elif val == 1:
|
||||
self.date2.set_active(1)
|
||||
elif val == 2:
|
||||
self.date3.set_active(1)
|
||||
|
||||
vbox.add(self.date1)
|
||||
vbox.add(self.date2)
|
||||
vbox.add(self.date3)
|
||||
|
||||
box.show_all()
|
||||
return p
|
||||
|
||||
def build_page4(self):
|
||||
p = gnome.ui.DruidPageStandard()
|
||||
p.set_title(_('Alternate calendar support'))
|
||||
p.set_title_foreground(self.fg_color)
|
||||
p.set_background(self.bg_color)
|
||||
p.set_logo(self.logo)
|
||||
|
||||
box = gtk.VBox()
|
||||
box.set_spacing(12)
|
||||
p.append_item("",box,"")
|
||||
|
||||
label = gtk.Label(_('By default, all dates stored by GRAMPS use the Gregorian calendar.\n'
|
||||
'This is normally sufficient for most users. Support may be enabled\n'
|
||||
'for the Julian, French Republican, and Hebrew calendar. If you believe\n'
|
||||
'that you will need one or more of these alternate calendars, enable\n'
|
||||
'alternate calendar support\n'))
|
||||
box.add(label)
|
||||
align = gtk.Alignment(0.5,0)
|
||||
box.add(align)
|
||||
vbox = gtk.VBox()
|
||||
vbox.set_spacing(6)
|
||||
box.show_all()
|
||||
return p
|
||||
|
||||
def build_page5(self):
|
||||
p = gnome.ui.DruidPageStandard()
|
||||
p.set_title(_('LDS extensions'))
|
||||
|
@ -28,20 +28,6 @@
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/gramps/preferences/date-entry</key>
|
||||
<applyto>/apps/gramps/preferences/date-entry</applyto>
|
||||
<owner>gramps</owner>
|
||||
<type>int</type>
|
||||
<default>0</default>
|
||||
<locale name="C">
|
||||
<short>Date entry format</short>
|
||||
<long>This key determines the date entry format. O corresponds to
|
||||
the MM/DD/YYYY (US format), 1 corrsponds to DD/MM/YYYY (European
|
||||
format), and 2 corresponds to YYYY-MM-DD (ISO format).</long>
|
||||
</locale>
|
||||
</schema>
|
||||
|
||||
<schema>
|
||||
<key>/schemas/apps/gramps/preferences/date-format</key>
|
||||
<applyto>/apps/gramps/preferences/date-format</applyto>
|
||||
|
@ -13,6 +13,11 @@
|
||||
<property name="default_height">500</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox5">
|
||||
@ -181,6 +186,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="overwrite">False</property>
|
||||
<property name="accepts_tab">True</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_WORD</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
@ -265,6 +272,8 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">False</property>
|
||||
<property name="overwrite">False</property>
|
||||
<property name="accepts_tab">True</property>
|
||||
<property name="justification">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap_mode">GTK_WRAP_NONE</property>
|
||||
<property name="cursor_visible">True</property>
|
||||
@ -486,6 +495,7 @@
|
||||
<property name="label">gtk-close</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="destroy_passed_object" object="status"/>
|
||||
</widget>
|
||||
</child>
|
||||
@ -500,4 +510,185 @@
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkDialog" id="encoding">
|
||||
<property name="width_request">400</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">GRAMPS - GEDCOM Encoding</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="has_separator">False</property>
|
||||
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="okbutton1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_default">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<property name="response_id">-5</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vbox6">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label17">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes"><span size="larger" weight="bold">GEDCOM Encoding</span></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">6</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label18">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">This GEDCOM file has identified itself as using ANSEL enconding. Sometimes, this is in error. If the imported data contains unusual characters, undo the import, and override the character set by selecting a different encoding below.</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">True</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">6</property>
|
||||
<property name="ypad">6</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox1">
|
||||
<property name="border_width">6</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">6</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hbox2">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">0</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label19">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Encoding: </property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="codeset">
|
||||
<property name="visible">True</property>
|
||||
<property name="items" translatable="yes">ANSEL
|
||||
ANSI (iso-8859-1)
|
||||
ASCII
|
||||
UNICODE</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
||||
|
@ -56,6 +56,7 @@ else:
|
||||
|
||||
try:
|
||||
locale.setlocale(locale.LC_ALL,'')
|
||||
locale.setlocale(locale.LC_TIME,os.environ.get('LANG','C'))
|
||||
except locale.Error:
|
||||
pass
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user