python-babel / flask-babel

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

Can I change the default value for BABEL_TRANSLATION_DIRECTORIES ? #120

Closed eualin closed 1 year ago

eualin commented 7 years ago

Hi,

I am struggling in figuring out how to tell flask_babel load the required files from a place other than then default one (i.e. /web/flask/app/).

When all three files (namely, babel.cfg, messages.pot and translations/) are in folder /web/flask/app/ then translations work perfect.

However, when I place files translations/ and messages.pot in /web/nginx/app/static/landing/babel/ (but leave files babel.cfg in /web/flask/app/) translations do not work. :(

Can you please let me know if the thing I am asking is doable and if so, how can I do that?

Note that BABEL_TRANSLATION_DIRECTORIES have been set as follows:

app.config['BABEL_TRANSLATION_DIRECTORIES'] = "../../nginx/app/static/landing/babel/translations;translations"

.
└── web
    ├── flask
    │   ├── app
    │   │   ├── babel.cfg
    │   │   ├── models.py
    │   │   ├── run.py
    │   │   ├── templates
    │   │   │   └── landing
    │   │   │       └── index.html
    │   │   ├── views.py
    ├── nginx
    │   ├── app
    │   │   └── static
    │   │       └── landing
    │   │           ├── babel
    │   │           │   ├── messages.pot
    │   │           │   └── translations
    │   │           │       └── el
    │   │           │           └── LC_MESSAGES
    │   │           │               ├── messages.mo
    │   │           │               └── messages.po
djetelina commented 6 years ago

This is such a poorly documented thing. Where does babel.cfg belong, where do translations belog, how configurable are they. The mapping file itself is not documented at all. And what does you have to get into the folder where you have your application mean - is that pythonpath, or workdir?

TkTech commented 6 years ago

PRs improving documentation and structure happily accepted.

djetelina commented 6 years ago

Great, I wasn't sure judging by no comments on many other PRs that are super old, but I'm going to submit something soon :)