0

I'm implementing i18n with flask_babel like below and it works in local server. However it doesn't work in production after deploy. It can show translated with "_('English')", however it does show {{ _('English')}} as is in HTML. Is there any way to show an appropriate message in HTML?

[main.py]

from flask_babel import gettext as _

@app.route('/', methods=['GET'])
def root():
    flash(_('English'), 'success')
    return render_template('index.html')

[index.html]

<!doctype html>
<html>
  <head>
  </head>
  <body>
    {{ _('English')}}
  </body>
</html>
Emiko
  • 21
  • 1
  • Are you getting any error on your logs? Also, could you share some screenshots to compare the expected vs what you are getting? – Luis Manuel Jan 06 '21 at 22:34
  • Thanks Luis for your kind advice! I've checked my log and found that there is no log shown even I set print(), that means my root() is not working correctly. After checking app.yaml, I've found that all html are uploaded static and that prevent dynamic language change. I removed unnecessary setting in app.yaml and it finally works as expected. Thanks again for your help! – Emiko Jan 09 '21 at 17:57

0 Answers0