From: Kevin A. <ka...@us...> - 2005-03-30 18:07:54
|
Update of /cvsroot/pythoncard/PythonCard In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10392 Modified Files: model.py Log Message: revised internationalResourceName to support platform-specific resources Index: model.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/model.py,v retrieving revision 1.190 retrieving revision 1.191 diff -C2 -d -r1.190 -r1.191 *** model.py 28 Sep 2004 21:24:24 -0000 1.190 --- model.py 30 Mar 2005 18:07:39 -0000 1.191 *************** *** 134,139 **** def internationalResourceName(base): ! aFileName = base + ".rsrc.py" try: default = locale.getdefaultlocale() --- 134,156 ---- + # KEA 2005-03-30 + # revised to support platform-specific resource files def internationalResourceName(base): ! postfix = ".rsrc.py" ! # build up a list of possible filenames ! # in order of preference and use the first one that exists ! filenames = [base + postfix] ! ! if wx.Platform == '__WXMSW__': ! platform = 'win' ! elif wx.Platform == '__WXGTK__': ! platform = 'gtk' ! elif wx.Platform == '__WXMAC__': ! platform = 'mac' ! else: ! platform = None ! if platform: ! filenames.insert(0, base + '.' + platform + postfix) ! try: default = locale.getdefaultlocale() *************** *** 141,155 **** default = None log.debug('default: ' + str(default)) if default and default[0] is not None: language, country = default[0].split('_') ! languageCountryName = base + '.' + language + '_' + country + ".rsrc.py" ! languageOnlyName = base + '.' + language + ".rsrc.py" ! if os.path.exists(languageCountryName): ! aFileName = languageCountryName ! elif os.path.exists(languageOnlyName): ! aFileName = languageOnlyName ! log.debug(language + ' ' + country + ' ' + languageCountryName + ' ' + \ ! languageOnlyName + ' ' + aFileName) ! return aFileName --- 158,180 ---- default = None log.debug('default: ' + str(default)) + if default and default[0] is not None: language, country = default[0].split('_') ! log.debug(language + ' ' + country) ! # languageOnlyName ! filenames.insert(0, base + '.' + language + postfix) ! # languageCountryName ! filenames.insert(0, base + '.' + language + '_' + country + postfix) ! # now with platform specified as well ! if platform: ! filenames.insert(0, base + '.' + platform + '.' + language + postfix) ! filenames.insert(0, base + '.' + platform + '.' + language + '_' + country + postfix) ! ! log.debug(filenames) ! for f in filenames: ! if os.path.exists(f): ! filename = f ! break ! return filename |