I have a python project with jinja templates and flask-babel working good. My problem are javascript files. I have all the js files inside a folder called 'static', but after using:
var food = gettext('food');
Then updating and compiling, the browser returns an error :
gettext is not defined
I've seen some projects using babel.js or jsil18n but I'm not sure if I really need that. How can I define gettext the same same way I did with my jinja templates?
如果 food 是一个字符串,那么您可以使用以下语法,前提是您的 messages.po 文件中有 food 的翻译:
var food = "{{_('food')}}";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.