I have a web application developed using python 2.7.6, flask and deployed on a Apache Ubuntu server.
For internationalization, the app uses the flask-babel
package in order to translate into Thai. However, it seems that my translations/th/LC_messages/messages.po
file is ignored.
It works perfectly in my localhost but not in the server. To force the selection of the locale, I use the code below:
@babel.localeselector def get_locale(): return 'th'
It seems there is something that might be missing in my configuration file but couldn’t figure it out.
If you have any ideas please feel free. Thank you.
Advertisement
Answer
I encountered this exact same issue! My babel translations were working fine when I ran the app locally, but on my apache server, none of the text was translating as expected.
After attempting a number of different fixes, I figured out that (for whatever reason), my custom get_locale
localeselector override function was not getting used by the app when it ran on the apache server.
I ended up explicitly importing the get_locale
function into the relevant view file, which resolved the issue.