--- gettext.py.orig 2007-02-07 16:32:42.000000000 -0800 +++ gettext.py 2007-02-07 16:48:43.000000000 -0800 @@ -418,8 +418,12 @@ # Locate a .mo file using the gettext strategy -def find(domain, localedir=None, languages=None, all=0): +def find(domain, localedir=None, languages=None, all=0, exists=None): # Get some reasonable defaults for arguments that were not supplied + # + # "exists" is a callback that takes a mofile and returns True if it + # actually exists. You only need to pass something if your + # translation catalogs don't exist in the filesystem like normal. if localedir is None: localedir = _default_localedir if languages is None: @@ -431,6 +435,8 @@ break if 'C' not in languages: languages.append('C') + if exists is None: + exists = os.path.exists # now normalize and expand the languages nelangs = [] for lang in languages: @@ -446,7 +452,7 @@ if lang == 'C': break mofile = os.path.join(localedir, lang, 'LC_MESSAGES', '%s.mo' % domain) - if os.path.exists(mofile): + if exists(mofile): if all: result.append(mofile) else: @@ -454,7 +460,6 @@ return result - # a mapping between absolute .mo file path and Translation object _translations = {}