2004-09-25 10:42:15 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2004 Donald N. Allingham
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
2004-09-17 09:00:04 +05:30
|
|
|
|
2004-09-25 10:42:15 +05:30
|
|
|
"""
|
|
|
|
Class handling language-specific selection for date parser and displayer.
|
|
|
|
"""
|
2004-09-17 09:00:04 +05:30
|
|
|
|
2004-09-25 10:42:15 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Standard python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
2004-11-09 09:53:34 +05:30
|
|
|
import locale
|
2004-09-25 10:42:15 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import GrampsGconfKeys
|
|
|
|
import DateParser
|
|
|
|
import DateDisplay
|
2004-09-17 09:00:04 +05:30
|
|
|
|
2004-09-25 10:42:15 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-11-09 09:53:34 +05:30
|
|
|
_lang = locale.getlocale(locale.LC_TIME)[0]
|
2004-09-17 09:00:04 +05:30
|
|
|
|
|
|
|
_lang_to_parser = {
|
2004-11-07 08:32:24 +05:30
|
|
|
'C' : DateParser.DateParser,
|
|
|
|
'en_US' : DateParser.DateParser,
|
|
|
|
'en_GB' : DateParser.DateParser,
|
|
|
|
'en_AU' : DateParser.DateParser,
|
|
|
|
'en_CA' : DateParser.DateParser,
|
|
|
|
'en_SE' : DateParser.DateParser,
|
|
|
|
'en' : DateParser.DateParser,
|
2004-09-17 09:00:04 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
_lang_to_display = {
|
2004-11-07 08:32:24 +05:30
|
|
|
'C' : DateDisplay.DateDisplay,
|
|
|
|
'en_US' : DateDisplay.DateDisplay,
|
|
|
|
'en_GB' : DateDisplay.DateDisplay,
|
|
|
|
'en_AU' : DateDisplay.DateDisplay,
|
|
|
|
'en_CA' : DateDisplay.DateDisplay,
|
|
|
|
'en_SE' : DateDisplay.DateDisplay,
|
|
|
|
'en' : DateDisplay.DateDisplay,
|
2004-09-17 09:00:04 +05:30
|
|
|
}
|
|
|
|
|
2004-09-25 10:42:15 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Functions
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-09-17 09:00:04 +05:30
|
|
|
def create_parser():
|
|
|
|
try:
|
|
|
|
return _lang_to_parser[_lang]()
|
|
|
|
except:
|
2004-11-07 08:32:24 +05:30
|
|
|
print "Date parser for",_lang,"not available"
|
2004-09-17 09:00:04 +05:30
|
|
|
return DateParser.DateParser()
|
|
|
|
|
|
|
|
def create_display():
|
|
|
|
try:
|
2004-09-25 10:42:15 +05:30
|
|
|
val = GrampsGconfKeys.get_date_format(_lang_to_display[_lang].formats)
|
2004-09-17 09:00:04 +05:30
|
|
|
return _lang_to_display[_lang](val)
|
|
|
|
except:
|
2004-11-07 08:32:24 +05:30
|
|
|
print "Date displayer for",_lang,"not available"
|
2004-09-17 09:00:04 +05:30
|
|
|
return DateDisplay.DateDisplay(3)
|
|
|
|
|
|
|
|
def get_date_formats():
|
|
|
|
try:
|
|
|
|
return _lang_to_display[_lang].formats
|
|
|
|
except:
|
|
|
|
return DateDisplay.DateDisplay.formats
|
|
|
|
|
|
|
|
def set_format(val):
|
|
|
|
try:
|
2004-09-25 10:42:15 +05:30
|
|
|
_lang_to_display[_lang].format = val
|
2004-09-17 09:00:04 +05:30
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
def get_format():
|
|
|
|
try:
|
2004-09-25 10:42:15 +05:30
|
|
|
return _lang_to_display[_lang].format
|
2004-09-17 09:00:04 +05:30
|
|
|
except:
|
|
|
|
print "not found"
|
|
|
|
return 0
|
2004-11-16 09:14:23 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Import localized date classes
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
from Plugins import load_plugins
|
|
|
|
from const import datesDir
|
|
|
|
load_plugins(datesDir)
|