I can translate strings in python and html files. But When I translate JavaScript strings, I get this error in browser console:
Uncaught ReferenceError: _ is not defined
My setup.py:
message_extractors={'wiki20': [
('**.py', 'python', None),
('templates/**.html', 'genshi', None),
('public/javascript/index.js', 'javascript', None),
('public/**', 'ignore', None)
]},
JavaScript file content:
$("#bulbunu2").html(_('jquery two add this..! bla2'));
When I run python setup.py extract_messages, I see js strings in .pot file,(command generate JavaScript strings) but browser give error.
How can I solve this problem?
TurboGears by itself does not provide a javascript gettext library, after you gathered and translated the strings like you probably already did you will need javascript library to read .po files and a javascript library to translate your strings.
You can use https://www.npmjs.com/package/po2json to read
.pofiles and convert them toJSON, then you can use http://slexaxton.github.io/Jed/ or any other translation library for the_()function itself.