python-babel / flask-babel

i18n and l10n support for Flask based on Babel and pytz
https://python-babel.github.io/flask-babel/
Other
432 stars 159 forks source link

question about .mo file caching mechanism #207

Closed 841020 closed 1 year ago

841020 commented 1 year ago

Hi there

I have a question So we all know that .mo will be cached in flask app I just want to know if when we run flask server it caches all .mo files at the beginning? Or is it just when we switch languages then it creates domain objects and caches that .mo file?

I thought caching all mo files at the beginning would minimize IO time

841020 commented 1 year ago

I checked the source code, I found that I misunderstood, it should be that each language will generate a cache in the Doamin object when it is used

In this way, the next time the language is switched, the cache can be obtained through key mapping from the Domain