Package DateHandler
[frames] | no frames]

Source Code for Package DateHandler

 1  # 
 2  # Gramps - a GTK+/GNOME based genealogy program 
 3  # 
 4  # Copyright (C) 2004-2007  Donald N. Allingham 
 5  # 
 6  # This program is free software; you can redistribute it and/or modify 
 7  # it under the terms of the GNU General Public License as published by 
 8  # the Free Software Foundation; either version 2 of the License, or 
 9  # (at your option) any later version. 
10  # 
11  # This program is distributed in the hope that it will be useful,  
12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
14  # GNU General Public License for more details. 
15  # 
16  # You should have received a copy of the GNU General Public License 
17  # along with this program; if not, write to the Free Software 
18  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
19  # 
20   
21  # $Id: __init__.py 10055 2008-02-18 20:07:09Z acraphae $ 
22   
23  """ 
24  Class handling language-specific selection for date parser and displayer. 
25  """ 
26   
27  # import prerequisites for localized handlers 
28  from _DateHandler import (LANG, LANG_SHORT, LANG_TO_PARSER, LANG_TO_DISPLAY,  
29                            register_datehandler) 
30   
31  # Import all the localized handlers 
32  import _Date_cs 
33  import _Date_de 
34  import _Date_es 
35  import _Date_fi 
36  import _Date_fr 
37  import _Date_lt 
38  import _Date_nb 
39  import _Date_nl 
40  import _Date_pl 
41  import _Date_pt 
42  import _Date_ru 
43  import _Date_sk 
44  import _Date_sv 
45   
46  # Initialize global parser 
47  try: 
48      if LANG_TO_PARSER.has_key(LANG): 
49          parser = LANG_TO_PARSER[LANG]() 
50      else: 
51          parser = LANG_TO_PARSER[LANG_SHORT]() 
52  except: 
53      print "Date parser for", LANG, "not available, using default" 
54      parser = LANG_TO_PARSER["C"]() 
55   
56  # Initialize global displayer 
57  try: 
58      import Config 
59      val = Config.get_date_format(LANG_TO_DISPLAY[LANG].formats) 
60  except: 
61      try: 
62          val = Config.get_date_format(LANG_TO_DISPLAY["C"].formats) 
63      except: 
64          val = 0 
65   
66  try: 
67      if LANG_TO_DISPLAY.has_key(LANG): 
68          displayer = LANG_TO_DISPLAY[LANG](val) 
69      else: 
70          displayer = LANG_TO_DISPLAY[LANG_SHORT](val) 
71  except: 
72      print "Date displayer for", LANG, "not available, using default" 
73      displayer = LANG_TO_DISPLAY["C"](val) 
74   
75   
76  # Import utility functions 
77  from _DateUtils import * 
78