[Python-checkins] CVS: python/dist/src/Lib gettext.py,1.11,1.12

Martin v. L?wis loewis@users.sourceforge.net
Thu, 10 Jan 2002 22:33:30 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv9971/Lib

Modified Files:
	gettext.py 
Log Message:
Add fallback argument to translation(). Request fallbacks on install.
Fixes #500595.


Index: gettext.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/gettext.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** gettext.py	2001/01/23 15:35:04	1.11
--- gettext.py	2002/01/11 06:33:28	1.12
***************
*** 231,239 ****
  _translations = {}
  
! def translation(domain, localedir=None, languages=None, class_=None):
      if class_ is None:
          class_ = GNUTranslations
      mofile = find(domain, localedir, languages)
      if mofile is None:
          raise IOError(ENOENT, 'No translation file found for domain', domain)
      key = os.path.abspath(mofile)
--- 231,242 ----
  _translations = {}
  
! def translation(domain, localedir=None, languages=None,
!                 class_=None, fallback=0):
      if class_ is None:
          class_ = GNUTranslations
      mofile = find(domain, localedir, languages)
      if mofile is None:
+         if fallback:
+             return NullTranslations()
          raise IOError(ENOENT, 'No translation file found for domain', domain)
      key = os.path.abspath(mofile)
***************
*** 249,253 ****
  
  def install(domain, localedir=None, unicode=0):
!     translation(domain, localedir).install(unicode)
  
  
--- 252,256 ----
  
  def install(domain, localedir=None, unicode=0):
!     translation(domain, localedir, fallback=1).install(unicode)