我可以翻译python和html文件中的字符串。但当我翻译JavaScript字符串时,浏览器控制台会出现以下错误:
Uncaught ReferenceError: _ is not defined
我的设置.py公司名称:
message_extractors={'wiki20': [
('**.py', 'python', None),
('templates/**.html', 'genshi', None),
('public/javascript/index.js', 'javascript', None),
('public/**', 'ignore', None)
]},
JavaScript文件内容:
$("#bulbunu2").html(_('jquery two add this..! bla2'));
当我运行python setup.py extract_messages
时,我在.pot文件中看到js字符串,(命令生成JavaScript字符串),但浏览器给出了错误。你知道吗
我怎样才能解决这个问题?你知道吗
TurboGears本身并不提供javascript gettext库,在收集和翻译字符串之后,您可能需要javascript库来读取.po文件,并需要javascript库来翻译字符串。你知道吗
您可以使用https://www.npmjs.com/package/po2json读取
.po
文件并将其转换为JSON
,然后您可以使用http://slexaxton.github.io/Jed/或_()
函数本身的任何其他翻译库。你知道吗相关问题 更多 >
编程相关推荐