Python internationalization library with an emphasis on web-based applications. Use with the [python] tag and any relevant version tags.
Questions tagged [python-babel]
158 questions
3
votes
1 answer
How can I display the date/time in multiple languages?
I would like to display the date and time (or either date or time, separately) in multiple languages. Specifically English and Spanish, but perhaps in other languages in the future.
I've considered pythons time.strftime function in combination with…

Buttons840
- 9,239
- 15
- 58
- 85
3
votes
2 answers
Flask, Jinja2, Babel error on "$" character
I'm migrated my code from webapp2 to Flask. (I deploy my code in Google App Engine)
However, I can no longer use this string: "Error: Max %1$d characters"
Initialization
flask_app = Flask(__name__)
babel = Babel(flask_app,…

Blodhgard
- 9,130
- 3
- 24
- 36
3
votes
2 answers
How to escape '%' character in jinja 2.10 {% trans %} using pybabel?
I am using jinja 2.10 and pybabel. When my template contains following code (with '%' char inside trans block) pybabel-compile does not translate the string. The extracted string (in .po) is OK but on the result page it is not translated at all.
Mirek
- 41
- 2

Mirek
- 41
- 2
3
votes
1 answer
Flask test setup with Flask-Babel
I'd like to setUp with unittest module.
My Flask App is created using factory (create_app) uses Flask-Babel for i18n/
def create_app(config=None, app_name=None, blueprints=None):
# Create Flask App instance
app_name = app_name or __name__
…

pincoin
- 665
- 5
- 19
3
votes
2 answers
babel flask jinja javascript hell
Is there a way for me to include flask jinja enclosed babel translations inside of my javascript file and load it in as if it was a static file? Or is the only way for me to do this to include this part of my code in the .html template file? I'm…

user805981
- 9,979
- 8
- 44
- 64
3
votes
1 answer
Using links with babel in Jinja2
Currently I'm using Flask and Jinja2 in combination with Babel. So far everything is working great.
The only problem I'm facing is when using links in a translated text. Let's say we have the following in HTML:
You can change this in your
Thorchy
3
votes
2 answers
Why 1 hour wrong?
The time is 15:0x in Stockholm (Europe). But I'm getting the localized time 1 hour wrong:
>>> datetime.datetime.now()
datetime.datetime(2015, 12, 17, 15, 2, 42, 633000)
>>> babel.dates.format_datetime(datetime.datetime.now(), 'full',…

Niklas Rosencrantz
- 25,640
- 75
- 229
- 424
3
votes
2 answers
Flask WTF localization with Babel
I've used Flask Babel and have localized my project, but I have a problem with WTF forms, I can't translate the fields shown when field is empty. Any help?
This is working:
return jsonify({'error': gettext('Incorrect Data')}), 406
but when dealing…
user4512548
3
votes
1 answer
How to use jinja2 i18n with bottle (with babel)
I believe to use jinja2 with bottle one simply uses jinja2_template instead of template:
e.g. bottle.jinja2_template("mytemplate", dict(name=value, name2=value2))
However if one needs the i18n jinja extension how is that best specified to also…

user3571113
- 31
- 3
3
votes
0 answers
One .pot per domain in Pyramid i18n
in a Pyramid application we have some sections and templates where we use different translation domains (appart from the default domain).
Currently, if we run python setup.py extract_messages, all translation strings from all domains are generated…

Roland Pish
- 815
- 1
- 9
- 21
3
votes
2 answers
Flask, Babel and python - ImportError: No module named babel
Despite installing babel I am rather amused yet annoyed that Flask and Babel do not work.
pip install babel
pip install Flask-Babel
Traceback (most recent call last):
File "run.py", line 8, in
from app import app
File…

Tampa
- 75,446
- 119
- 278
- 425
3
votes
2 answers
python gettext different languages at same time
I'm using flask, pybabel for i18n. Sometimes I need to send emails to my users. And I want to send email in their own language. Language code stores in databases so the problem is to translate template with right language. Here is part of my sending…

krasulya
- 511
- 6
- 17
3
votes
1 answer
Blacklist jinja2 custom tags in pybabel configuration file
I am using pybabel to translate wordings in my templates. Templates are handled by jinja2. I created a jinja2 Extension to automatically generate my breadcrumb.
However, extracting the wordings with babel is now impossible:
pybabel extract -F…

krakax
- 79
- 1
- 5
3
votes
0 answers
Babel and jinja2 with coffin extension
I'm trying to translate a jinja2/coffin template with Babel using the command line tool. The issue is that the function babel_extract jams on the coffin tags like {% url %} or {% csrf_token %}.
First, to detect the problem, I have modify…

goodfriend0
- 193
- 1
- 8
3
votes
1 answer
mustache, babel and gettext
I am using Flask, jinja together with Mustachjs.
In order to get the job done I am using the {% raw %} tag.
Now, it is a multi-languages application and I use Babel.
How can I do :
{% raw %}