First time here? Check out the FAQ!
1

Does jinja2_makemessages miss some messages?!
 

According to this question jinja2_makemessages is supposed to work fine with templates. But in my latest update from the Github repo I'm noticing that some strings are being skipped. For example the sort by button labels on questions page: 'by date', 'by activity', 'by answers', 'by votes'.

Am I doing something wrong?! I'm just doing the same thing I used to do before:

python /path/to/manage.py jinja2_makemessages -l xx -e html,py,txt

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Basel Shishani's avatar
197
Basel Shishani
asked 13 years ago

Comments

see more comments

2 Answers

1

It does miss those messages when used in a specific way in the jinja2 templates. To work around this problem, the messages are added to file askbot/const/messages.py there is only about a dozen of messages like these.

At some point I've changed "votes" -> "by votes" etc, to make them different from simply "votes" (sometimes you need both in the language files) and forgot to update the askbot/const/messages.py.

So now they are not missed.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 13 years ago
link

Comments

Evgeny, thanks for the answer and I really appreciate the time you're devoting to this. May I ask, is this some dormant bug in (jinja2_)makemessage to be addressed at some point in the future, or is it a known/understood inherent issue in the way makemessages - gettext - templates interact together. If you have a pointer on this it will do me.

Basel Shishani's avatar Basel Shishani (13 years ago)

Maybe there is a fix to this, but I could not find it easily, the issue is with {{ gettext('somemessage') }} type of calls in the template. Possibly some regexes in the jinja2_makemessages could be fixed.

Evgeny's avatar Evgeny (13 years ago)

And just a small correction on askbot/const/message_keys.py

Basel Shishani's avatar Basel Shishani (13 years ago)
see more comments
0

I have the same issue, posted here, and I work around this by deleting, inside .po file, all #~ that actually comment out my useful, translated pairs. May that would work for you two.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
zaf's avatar
512
zaf
answered 13 years ago
link

Comments

I think that was accidental for you. If you run makemessages again it will comment out your translations once more. The workaround explained by Evgeny works fine for now. The issue he mentioned is explained in detail in the jinja2_makemessages module doc.

Basel Shishani's avatar Basel Shishani (13 years ago)
see more comments