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

How to translate third party packages #199

Closed swoiow closed 2 years ago

swoiow commented 2 years ago

As title.. and the more details:

I want to translate falsk-admin html to others language, how to include those templates files?

born2discover commented 2 years ago

I believe this might be what you're looking for: Translating Applications. It gives you a series of steps to follow in order to produce necessary translation files.

swoiow commented 2 years ago

Thanks your answer @born2discover . Yeah, i just tested it again before i writing.

The doc provide the situation work good when the the venv folder under the project folder, just like that

+ projectFolder
  - venv
  - babel.cfg
  - .... more others folders

so run pybabel extract -F babel.cfg -o messages.pot . is ok, and more extensions=jinja2.ext.autoescape,jinja2.ext.with_ is not need any more in latest jinja2.

But, how about the venv is not under the project, maybe use system env? That is not work for me. Any suggestions?

born2discover commented 2 years ago

venv folder is traditionally used for virtual environments in order to isolate dependencies on a per-project basis. However, strictly speaking they are not a requirement. That is, one can install everything system-wide and it'll work fine-ish.

So in your case, you could just as well install Babel (the underlying library that flask-babel extends) system-wide with: pip install Babel or sudo pip install Babel.

From there, pybabel command should be accessible to you in terminal without any virtualenv.

swoiow commented 2 years ago

Thanks @born2discover . You give the best help for me.