在开发人员机器上运行由.net应用程序调用的ironpython应用程序时,我们从ironpython获得错误ioerror。在跟踪错误时,我们看到它来自翻译函数中的gettext.py。它似乎与default_LocaleDir变量有关,该变量显示:“file:///c:/windows/microsoft.net/assembly/gac_MSIL/ironpython/v4.0_2.7.9.0_7f709c5b713576e1/ironpython.dll\share\locale”
该应用程序在我们的测试和生产服务器上运行得非常好,因此看起来像是配置问题。
我们试图将pythonpath环境变量设置为c:\ program files\ironpython 27,这是ironpython软件下载到的位置,但没有什么不同。
def translation(domain, localedir=None, languages=None,
class_=None, fallback=False, codeset=None):
if class_ is None:
class_ = GNUTranslations
mofiles = find(domain, localedir, languages, all=1)
if not mofiles:
if fallback:
return NullTranslations()
raise IOError(ENOENT, 'No translation file found for domain', domain)
result = None
for mofile in mofiles:
key = (class_, os.path.abspath(mofile))
t = _translations.get(key)
if t is None:
with open(mofile, 'rb') as fp:
t = _translations.setdefault(key, class_(fp))
t = copy.copy(t)
if codeset:
t.set_output_charset(codeset)
if result is None:
result = t
else:
result.add_fallback(t)
return result
当查看结果时,它显示为空。
我们没有对gettext.py或任何标准的python代码做任何更改。