diff --git a/wxPython/demo/Main.py b/wxPython/demo/Main.py index c7b768b383..ac8e90165d 100644 --- a/wxPython/demo/Main.py +++ b/wxPython/demo/Main.py @@ -19,6 +19,7 @@ from wxPython.html import wxHtmlWindow import images + #--------------------------------------------------------------------------- @@ -702,6 +703,11 @@ class MyApp(wxApp): Create and show the splash screen. It will then create and show the main frame when it is time to do so. """ + + #import locale + #self.locale = wxLocale(wxLANGUAGE_FRENCH) + #locale.setlocale(locale.LC_ALL, 'fr') + wxInitAllImageHandlers() splash = MySplashScreen() splash.Show() diff --git a/wxPython/distrib/make_installer.py b/wxPython/distrib/make_installer.py index 9f917f2854..5847a5cebf 100644 --- a/wxPython/distrib/make_installer.py +++ b/wxPython/distrib/make_installer.py @@ -98,6 +98,8 @@ Source: "wxPython\lib\PyCrust\*.txt"; DestDir: "{app}\wxPython\lib\PyCrust Source: "wxPython\lib\PyCrust\*.ico"; DestDir: "{app}\wxPython\lib\PyCrust"; Components: core Source: "wxPython\lib\colourchooser\*.py"; DestDir: "{app}\wxPython\lib\colourchooser"; Components: core +%(LOCALE)s + Source: "demo\*.py"; DestDir: "{app}\wxPython\demo"; Components: demo Source: "demo\*.xml"; DestDir: "{app}\wxPython\demo"; Components: demo Source: "demo\*.txt"; DestDir: "{app}\wxPython\demo"; Components: demo @@ -348,6 +350,22 @@ def find_DLLs(): return WXDLL, PYTHONVER +#---------------------------------------------------------------------- + +def build_locale_string(): + template = 'Source: "%s"; DestDir: "{app}\%s"; Components: core' + stringlst = [] + + def walk_helper(lst, dirname, files): + for f in files: + filename = os.path.join(dirname, f) + if not os.path.isdir(filename): + lst.append( template % (filename, dirname) ) + + os.path.walk('wxPython\\locale', walk_helper, stringlst) + return '\n'.join(stringlst) + + #---------------------------------------------------------------------- def main(): @@ -366,6 +384,7 @@ def main(): SYSDIR = r"C:\WINNT\SYSTEM32" ISSFILE = "__wxPython.iss" IFSFILE = "__wxPython.ifs" + LOCALE = build_locale_string() if PYTHONVER >= "2.2": IF22 = r"InstallDir := InstallDir + '\Lib\site-packages';" diff --git a/wxPython/setup.py b/wxPython/setup.py index 618865914e..021930f41a 100755 --- a/wxPython/setup.py +++ b/wxPython/setup.py @@ -6,6 +6,8 @@ from distutils.core import setup, Extension from distutils.file_util import copy_file from distutils.dir_util import mkpath from distutils.dep_util import newer +from distutils.spawn import spawn +from distutils.command.install_data import install_data #---------------------------------------------------------------------- # flags and values that affect this script @@ -21,7 +23,7 @@ LONG_DESCRIPTION = """\ wxPython is a GUI toolkit for Python that is a wrapper around the wxWindows C++ GUI library. wxPython provides a large variety of window types and controls, all implemented with a native look and -feel (and native runtime speed) on the platforms it is supported +feel (by using the native widgets) on the platforms it is supported on. """ @@ -135,6 +137,7 @@ def libFlag(): PKGDIR = 'wxPython' wxpExtensions = [] +DATA_FILES = [] force = '--force' in sys.argv or '-f' in sys.argv debug = '--debug' in sys.argv or '-g' in sys.argv @@ -215,12 +218,9 @@ def Verify_WX_CONFIG(): WX_CONFIG = 'wx-config' + def run_swig(files, dir, gendir, package, USE_SWIG, force, swig_args, swig_deps=[]): """Run SWIG the way I want it done""" - from distutils.file_util import copy_file - from distutils.dep_util import newer - from distutils.spawn import spawn - if not os.path.exists(os.path.join(dir, gendir)): os.mkdir(os.path.join(dir, gendir)) @@ -246,7 +246,7 @@ def run_swig(files, dir, gendir, package, USE_SWIG, force, swig_args, swig_deps= i_file = '/'.join(i_file.split('\\')) cmd = ['./wxSWIG/wxswig'] + swig_args + ['-I'+dir, '-c', '-o', cpp_file, i_file] - print ' '.join(cmd) + msg(' '.join(cmd)) spawn(cmd) # copy the generated python file to the package directory @@ -264,6 +264,40 @@ def contrib_copy_tree(src, dest, verbose=0): copy_tree(src, dest, update=1, verbose=verbose) + +class smart_install_data(install_data): + def run(self): + #need to change self.install_dir to the actual library dir + install_cmd = self.get_finalized_command('install') + self.install_dir = getattr(install_cmd, 'install_lib') + return install_data.run(self) + + +def build_locale_dir(destdir, verbose=1): + """Build a locale dir under the wxPython package for MSW""" + moFiles = glob.glob(opj(WXDIR, 'locale', '*.mo')) + for src in moFiles: + lang = os.path.splitext(os.path.basename(src))[0] + dest = opj(destdir, lang, 'LC_MESSAGES') + mkpath(dest, verbose=verbose) + copy_file(src, opj(dest, 'wxstd.mo'), update=1, verbose=verbose) + + +def build_locale_list(srcdir): + # get a list of all files under the srcdir, to be used for install_data + def walk_helper(lst, dirname, files): + for f in files: + filename = opj(dirname, f) + if not os.path.isdir(filename): + lst.append( (dirname, [filename]) ) + file_list = [] + os.path.walk(srcdir, walk_helper, file_list) + return file_list + + + + + #---------------------------------------------------------------------- # sanity checks @@ -510,6 +544,11 @@ if IN_CVS_TREE: # update the license files copy_file(opj(WXDIR, 'docs', file), opj('licence',file), update=1, verbose=0) +if os.name == 'nt': + build_locale_dir(opj(PKGDIR, 'locale')) + DATA_FILES += build_locale_list(opj(PKGDIR, 'locale')) + + if os.name == 'nt': rc_file = ['src/wxc.rc'] else: @@ -1174,8 +1213,11 @@ if __name__ == "__main__": options = { 'build' : { 'build_base' : BUILD_BASE }}, - ##data_files = TOOLS, scripts = SCRIPTS, + + cmdclass = { 'install_data': smart_install_data}, + data_files = DATA_FILES, + ) diff --git a/wxPython/src/_extras.py b/wxPython/src/_extras.py index 8875f57130..46f127b424 100644 --- a/wxPython/src/_extras.py +++ b/wxPython/src/_extras.py @@ -632,6 +632,12 @@ if wxPlatform == "__WXGTK__": except: pass +if wxPlatform == "__WXMSW__": + import os + localedir = os.path.join(os.path.split(__file__)[0], "locale") + wxLocale_AddCatalogLookupPathPrefix(localedir) + del os + #---------------------------------------------------------------------- # wxWindows version numbers. wxPython version is in __version__.