Thread safe locale techniques

主宰稳场 提交于 2019-12-10 15:14:37

问题


We're currently writing a web application based on a threaded python web server framework (cherrypy) and would like to simultaneously support users from multiple locales.

The locale module doesn't appear to be thread safe. Are there 3rd party libraries or modules that provide locale parsing and formatting functionality in a thread-safe way?

Suggestions appreciated!

Regards, Malcolm


回答1:


pyIcu has some such functionality (and other great support for i18n/l10n tasks), and I've been using it some of the time, but it's far from a smooth port of locale-based code -- you'll basically have to rewrite your code for it. Also, it doesn't support environments where you're not allowed to install arbitrary extensions, such as App Engine and some other hosted environments. Unfortunately I don't know of a good alternative without such constraints:-(.




回答2:


Babel is an excellent library for all your thread-safe i18n needs plus a pluggable framework to extract messages from Python sources and web templates.



来源:https://stackoverflow.com/questions/2186327/thread-safe-locale-techniques

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!