* src/DateHandler.py: handle generic "en", "fr" cases as a fallback

if the unknown "yy_XX" code is passed. Try yy if yy_XX fails.
* src/dates/Date_*.py: add a default xx case


svn: r4783
This commit is contained in:
Don Allingham 2005-06-04 19:08:38 +00:00
parent c5b68976e1
commit 078cafc0c8
7 changed files with 23 additions and 42 deletions

View File

@ -1,3 +1,8 @@
2005-06-04 Don Allingham <don@gramps-project.org>
* src/DateHandler.py: handle generic "en", "fr" cases as a fallback
if the unknown "yy_XX" code is passed. Try yy if yy_XX fails.
* src/dates/Date_*.py: add a default xx case
2005-06-03 Don Allingham <don@gramps-project.org>
* src/DateHandler.py: add more English locales
* src/dates/Date_fi.py: fix estimated/calculated, handle span

View File

@ -46,44 +46,18 @@ import DateDisplay
#
#-------------------------------------------------------------------------
_lang = locale.getlocale(locale.LC_TIME)[0]
if _lang:
_lang_short = _lang.split('_')[0]
else:
_lang_short = "C"
_lang_to_parser = {
'C' : DateParser.DateParser,
'en_AU' : DateParser.DateParser,
'en_BW' : DateParser.DateParser,
'en_CA' : DateParser.DateParser,
'en_DK' : DateParser.DateParser,
'en_GB' : DateParser.DateParser,
'en_HK' : DateParser.DateParser,
'en_IE' : DateParser.DateParser,
'en_IN' : DateParser.DateParser,
'en_NZ' : DateParser.DateParser,
'en_PH' : DateParser.DateParser,
'en_SE' : DateParser.DateParser,
'en_SG' : DateParser.DateParser,
'en_US' : DateParser.DateParser,
'en_ZA' : DateParser.DateParser,
'en_ZW' : DateParser.DateParser,
'en' : DateParser.DateParser,
}
_lang_to_display = {
'C' : DateDisplay.DateDisplayEn,
'en_AU' : DateDisplay.DateDisplayEn,
'en_BW' : DateDisplay.DateDisplayEn,
'en_CA' : DateDisplay.DateDisplayEn,
'en_DK' : DateDisplay.DateDisplayEn,
'en_GB' : DateDisplay.DateDisplayEn,
'en_HK' : DateDisplay.DateDisplayEn,
'en_IE' : DateDisplay.DateDisplayEn,
'en_IN' : DateDisplay.DateDisplayEn,
'en_NZ' : DateDisplay.DateDisplayEn,
'en_PH' : DateDisplay.DateDisplayEn,
'en_SE' : DateDisplay.DateDisplayEn,
'en_SG' : DateDisplay.DateDisplayEn,
'en_US' : DateDisplay.DateDisplayEn,
'en_ZA' : DateDisplay.DateDisplayEn,
'en_ZW' : DateDisplay.DateDisplayEn,
'en' : DateDisplay.DateDisplayEn,
'zh_CN' : DateDisplay.DateDisplay,
'zh_TW' : DateDisplay.DateDisplay,
@ -143,7 +117,10 @@ load_plugins(datesDir)
#-------------------------------------------------------------------------
try:
parser = _lang_to_parser[_lang]()
if _lang_to_parser.has_key(_lang):
parser = _lang_to_parser[_lang]
else:
parser = _lang_to_parser[_lang_short]
except:
print "Date parser for",_lang,"not available, using default"
parser = _lang_to_parser["C"]()
@ -158,7 +135,10 @@ except:
val = 0
try:
displayer = _lang_to_display[_lang](val)
if _lang_to_display.has_key(_lang):
displayer = _lang_to_display[_lang](val)
else:
displayer = _lang_to_display[_lang_short](val)
except:
print "Date displayer for",_lang,"not available, using default"
displayer = _lang_to_display["C"](val)

View File

@ -224,9 +224,5 @@ class DateDisplayDE(DateDisplay):
#
#-------------------------------------------------------------------------
from DateHandler import register_datehandler
register_datehandler(('de_DE','german'),DateParserDE, DateDisplayDE)
register_datehandler(('de_AT','german (Austria)'),DateParserDE, DateDisplayDE)
register_datehandler(('de_CH','german (Switzerland)'),DateParserDE, DateDisplayDE)
register_datehandler(('de_LI','german (Lichtenstein)'),DateParserDE, DateDisplayDE)
register_datehandler(('de_LU','german (Luxembourg)'),DateParserDE, DateDisplayDE)
register_datehandler(('de_BE','german (Belgium)'),DateParserDE, DateDisplayDE)
register_datehandler(('de_DE','german','de_AT','de_CH',
'de_LI','de_LU','de_BE','de'),DateParserDE, DateDisplayDE)

View File

@ -159,4 +159,4 @@ class DateDisplayES(DateDisplay):
#
#-------------------------------------------------------------------------
from DateHandler import register_datehandler
register_datehandler(('es_ES','spanish'),DateParserES, DateDisplayES)
register_datehandler(('es_ES','es','spanish'),DateParserES, DateDisplayES)

View File

@ -177,5 +177,5 @@ class DateDisplayFI(DateDisplay):
#
#-------------------------------------------------------------------------
from DateHandler import register_datehandler
register_datehandler(('fi_FI','finnish'), DateParserFI, DateDisplayFI)
register_datehandler(('fi_FI','fi','finnish'), DateParserFI, DateDisplayFI)

View File

@ -153,4 +153,4 @@ class DateDisplayFR(DateDisplay):
#
#-------------------------------------------------------------------------
from DateHandler import register_datehandler
register_datehandler(('fr_FR','french'),DateParserFR, DateDisplayFR)
register_datehandler(('fr_FR','fr','french'),DateParserFR, DateDisplayFR)

View File

@ -168,4 +168,4 @@ class DateDisplayRU(DateDisplay):
#
#-------------------------------------------------------------------------
from DateHandler import register_datehandler
register_datehandler(('ru_RU','russian'),DateParserRU, DateDisplayRU)
register_datehandler(('ru_RU','ru','russian'),DateParserRU, DateDisplayRU)