2

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?

1 Answer 1

1

If food is a string, then you can use the following syntax provided you have the translation for food in your messages.po file:

var food = "{{_('food')}}";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.