|
From: Kevin A. <al...@se...> - 2002-01-22 19:11:40
|
I made a small change to model.py to support automatically loading a
localized resource file, if available. The function is at the end of this
message if you're curious. It checks the default locale when it starts up to
get the language and country abbreviations.
Francois sent me this debug output (use the -l logging option) from his
machine:
DEBUG: : Tue Jan 22 15:39:26 2002: default: ('fr_FR', 'cp1252')
DEBUG: : Tue Jan 22 15:39:26 2002: fr FR minimal.fr_FR.rsrc.py
minimal.fr.rsrc.py minimal.fr_FR.rsrc.py
In addition to the model.py change, I checked in a minimal.fr.rsrc.py file.
I dropped the country code since it should work for French users outside
France as well. If the sample had some string, currency, or other
differences that required the country code, the name would have been
'minimal.fr_FR.rsrc.py'; FR is the country abbreviation for France.
I have to make some much deeper changes in order to support automatic string
substitution when the resource file is loaded, but this will get us started
to identify issues. I might add a localize option to the resourceEditor in
the next release.
I don't want to check into cvs two or three (certainly not ten or more)
different localized resource files for every sample. If we have one sample
designed to test international issues then we can have a lot of different
localized versions for that one sample. The resourceEditor will almost
certainly have a lot of localized files. I'm already inclined to have an
'international' or 'localized' folder where the resource files other than
the default English, United States file are stored to reduce clutter.
Later we'll need to think about how users would find localized versions of
apps or where we might provide a place to get them, possibly automatically
via a standard web page, XML-RPC service, etc. Until the current resource
file loading is changed (it uses eval() but should use import) you don't
want people downloading random resource files to run on their local system.
Same problem as downloading and running any program or script, but in the
case of resource files, users wouldn't expect that the resource could be
dangerous.
BTW, the localized resource files work with standalones built with py2exe
and Gordon's installer (that package needs another name). The resource files
are distributed with the standalone or a user adds one later and when the
standalone starts up it loads the resource dynamically, just like it does
when you use the script. Cool, no?! Of course, the actual program needs to
be international aware in its logic and string handling too, so I'll get
strings into the resource format soon.
I'm glad we are starting this process now so that we can find a workable
long-term solution.
ka
---
def internationalResourceName(base):
aFileName = base + ".rsrc.py"
default = locale.getdefaultlocale()
log.debug('default: ' + str(default))
if default[0] != 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
|