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

Is it possible to set directories at runtime? #238

Open kingkong-cmd opened 6 months ago

kingkong-cmd commented 6 months ago

Hi,

I am wondering if it is possible to somehow set directories/translation_directories at runtime the same way you can point locale_selector to a function that runs at every request?

I have been using flask-babel a bit outside of it's intended scope where I have translation paths like translations/app_1 and translations/app_2 where both can have 'en'/'es'/'ge' translations, with slight variations that are not actual translations (e.g. 'car' in app_1 is "translated" to 'boat' in app_2). This setup works fine if i run separate instances of the apps where I set the default paths in config for each app, but I'm trying to find a way to run as a single instance app, but need to point to correct translations path+file at runtime.