Trees | Indices | Help |
|
---|
|
1 # 2 # Gramps - a GTK+/GNOME based genealogy program 3 # 4 # Copyright (C) 2004-2006 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: _DateHandler.py 9912 2008-01-22 09:17:46Z acraphae $ 22 23 """ 24 Class handling language-specific selection for date parser and displayer. 25 """ 26 27 #------------------------------------------------------------------------- 28 # 29 # Python modules 30 # 31 #------------------------------------------------------------------------- 32 import locale 33 34 #------------------------------------------------------------------------- 35 # 36 # set up logging 37 # 38 #------------------------------------------------------------------------- 39 import logging 40 log = logging.getLogger(".DateHandler") 41 42 #------------------------------------------------------------------------- 43 # 44 # GRAMPS modules 45 # 46 #------------------------------------------------------------------------- 47 from _DateParser import DateParser 48 from _DateDisplay import DateDisplay, DateDisplayEn 49 50 #------------------------------------------------------------------------- 51 # 52 # Constants 53 # 54 #------------------------------------------------------------------------- 55 LANG = locale.getlocale(locale.LC_TIME)[0] 56 if LANG: 57 LANG_SHORT = LANG.split('_')[0] 58 else: 59 LANG_SHORT = "C" 60 61 LANG_TO_PARSER = { 62 'C' : DateParser, 63 'en' : DateParser, 64 'English_United States' : DateParser, 65 } 66 67 LANG_TO_DISPLAY = { 68 'C' : DateDisplayEn, 69 'en' : DateDisplayEn, 70 'English_United States' : DateDisplayEn, 71 'zh_CN' : DateDisplay, 72 'zh_TW' : DateDisplay, 73 'zh_SG' : DateDisplay, 74 'zh_HK' : DateDisplay, 75 'ja_JP' : DateDisplay, 76 'ko_KR' : DateDisplay, 77 } 7880 """ 81 Registers the passed date parser class and date displayer 82 classes with the specfied language locales. 83 84 @param locales: tuple of strings containing language codes. 85 The character encoding is not included, so the langauge 86 should be in the form of fr_FR, not fr_FR.utf8 87 @type locales: tuple 88 @param parse_class: Class to be associated with parsing 89 @type parse_class: DateParse 90 @param display_class: Class to be associated with displaying 91 @type display_class: DateDisplay 92 """ 93 for lang_str in locales: 94 LANG_TO_PARSER[lang_str] = parse_class 95 LANG_TO_DISPLAY[lang_str] = display_class96
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Sun Mar 9 21:52:59 2008 | http://epydoc.sourceforge.net |