Changeset 3278

Show
Ignore:
Timestamp:
07/25/2007 04:05:11 PM (1 year ago)
Author:
paul
Message:

This is a slightly better fix for the locale problem in py2exe apps: it doesn't rely on os.getcwd() which can vary depending on where you start the app

Files:

Legend:

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

    r3274 r3278  
    1 # -*- coding: utf-8 -*- 
     1# -*- coding: utf-8 -*- 
    22import gettext 
    33import locale 
     
    3636            try: 
    3737                lang = {"english": "en",  
    38                         "spanish": "es", "espanol": "es", "español": "es", 
    39                         "french": "fr", "francais": "fr", "français": "fr",  
     38                        "spanish": "es", "espanol": "es", "español": "es", 
     39                        "french": "fr", "francais": "fr", "français": "fr",  
    4040                        "german": "de", "deutsch": "de",  
    4141                        "italian": "it", "italiano": "it",  
    42                         "portuguese": "pt", "portuguése": "pt", 
     42                        "portuguese": "pt", "portuguése": "pt", 
    4343                        "russian": "ru"}[lang] 
    4444            except KeyError: 
     
    6969if not os.path.exists(daboLocaleDir): 
    7070    # Frozen app? 
    71     daboLocaleDir = os.path.join(os.getcwd(), "dabo.locale") 
     71    # First need to find the directory that contains the .exe: 
     72    startupDir = daboLocaleDir 
     73    while startupDir: 
     74        startupDir = os.path.split(startupDir)[0] 
     75        if os.path.isdir(startupDir): 
     76            break 
     77    daboLocaleDir = os.path.join(startupDir, "dabo.locale") 
     78#   raise ValueError, daboLocaleDir 
     79 
    7280_trans = {"en": None, "fr": None, "es": None, "pt": None, "ru": None, "de": None, "it": None} 
    7381defLang, defCharset = locale.getlocale()