Changeset 3274

Show
Ignore:
Timestamp:
07/24/2007 12:25:18 AM (1 year ago)
Author:
paul
Message:

My frozen app couldn't find the locale directory, resulting in the IOError to be raised from setLanguage(). I couldn't figure out how to point Dabo to the locale directory inside the zipfile, so I added a naming convention for 'dabo.locale': if that directory exists in os.getcwd() upon app start, then that's what is used if the actual dabo/locale directory isn't found. I realize this isn't optimal: it is just a stopgap so I can release my app to my client once again.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dLocalize.py

    r3268 r3274  
    1515    for lang in langs: 
    1616        pathparts = lang.split(sep) 
    17         pos = pathparts.index("locale") 
     17        try: 
     18            pos = pathparts.index("locale") 
     19        except ValueError: 
     20            # frozen App? 
     21            pos = pathparts.index("dabo.locale") 
    1822        ret.append(pathparts[pos+1]) 
    1923    return ret 
     
    4145                pass 
    4246    if not lang in getLanguages(): 
    43         raise IOError, "Invalid language '%s'" % lang 
     47        raise IOError, "Invalid language '%s' (localeDir: %s)" % (lang, daboLocaleDir) 
    4448     
    4549    if _trans.get(lang) is None: 
     
    6367 
    6468daboLocaleDir = os.path.join(os.path.split(dabo.__file__)[0], "locale") 
     69if not os.path.exists(daboLocaleDir): 
     70    # Frozen app? 
     71    daboLocaleDir = os.path.join(os.getcwd(), "dabo.locale") 
    6572_trans = {"en": None, "fr": None, "es": None, "pt": None, "ru": None, "de": None, "it": None} 
    6673defLang, defCharset = locale.getlocale()