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
4
votes
1 answer
How to change language of flask babel on a button click?
I have the function in Flask, which returns the website in english. Moreover, i want to be able to use german in the website at a button push from html. How can I change the language at a button push from english to german and from german to…

moro_922
- 113
- 8
4
votes
3 answers
Where should the python babel mapping configuration file be placed or named for standalone script?
I am currently trying to use Babel to generate a set of static html pages in different languages using Jinja2 within a simple script (not as part of a web app)
I am at the point where I need to extract the messages for translation and I know that I…

sasker
- 2,221
- 2
- 21
- 26
4
votes
0 answers
Flask - Babel - crumbled diacritics
I need to create translations for a Flask application using Babel or Babelex.
Run:
pybabel extract -F babel.cfg -o messages.pot .
...succeeds, creating messages.pot.
In the file messages.pot there are changes:
#: service/menu/Menu.py:53
msgid "A…

Jarda
- 89
- 5
4
votes
1 answer
Using Babel in a Pyramid Project with Jinja2
I have a Pyramid project that uses Jinja2. I am trying to use Babel by adding the following to the setup.py
message_extractors = { '.': [
('**.py', 'python', None ),
('static/**', 'ignore', None),
('resources/**',…

QLands
- 2,424
- 5
- 30
- 50
4
votes
2 answers
flask-babel: how to translate variables
I am using flask-babel for translating a Flask-based web application. I really want to know how can I translate the content of a variable, say foo.
I try {{ _(foo) }}, but when I update the .po files like this:
pybabel extract -F babel.cfg -k…

somenxavier
- 1,206
- 3
- 20
- 43
4
votes
1 answer
How to pass to url_for default params?
I develops multi language web site.
Pages have URI's like this:
/RU/about
/EN/about
/IT/about
/JP/about
/EN/contacts
and in jinja2 templates I write:
About
I have to write…

dhythhsba
- 972
- 2
- 11
- 21
4
votes
1 answer
Flask Babel doesn't work
I use Flask Babel to do I18N for flask admin project. But cannot make it works, even with simple template.
Here are the codes, initialize babel…

Xiaokun
- 814
- 2
- 10
- 26
4
votes
3 answers
Babel numbers format_currency function
I am working on a site where we use many languages and in order to display the price/currency accordingly we make use of babel library. The issue is when calling the format_currency it returns always the cent part if even if the price is explicitly…

Palmer
- 493
- 4
- 13
4
votes
2 answers
Org-mode babel python session does not produce results
I'm trying to write up a code test case using org-mode and babel but can't get past the first step:
* Running code example
Set up some variables
#+begin_src python :results output :session
x=1
#+end_src
Use some variables (in the end I'll have…

Dave
- 7,555
- 8
- 46
- 88
4
votes
3 answers
Get current locale in Jinja2
On my website use Flask + Jinja2, and Flask-Babel for translation. The site has two languages (depending on the URL), and I'd want to add a link to switch between them. To do this correctly I need to get the name of the current locale, but I didn't…

aplavin
- 2,199
- 5
- 32
- 53
4
votes
2 answers
Python, flask, babel- message, and e.g. Spanish - How to
I am utterly confused with trying to use babel with flask for language translation.
Lets assume the following. A user has a preferance of spanish over english. I have a variable that marks this:
g.user.default_language='sp'
Lets say I have to…

Tampa
- 75,446
- 119
- 278
- 425
3
votes
1 answer
Mako, Babel and string interpolation
I'm trying to do something like this:
${_('Hello ${name}, welcome to...', mapping=dict(name='${name}'))}
Where _() is my Babel translation function, the first ${name} is string interpolation I'd like to be performed by Babel and the second ${name}…

ryonlife
- 6,563
- 14
- 51
- 64
3
votes
1 answer
Babel formatting error for negative values in currency
I try to format floats into currency-strings with babel. The following code:
from babel.numbers import format_currency
print(format_currency(value, 'CHF', locale='de_CH'))
print(format_currency(value, 'CHF', '¤¤ #,##0.00',…

user2828408
- 65
- 1
- 2
- 6
3
votes
1 answer
How to use React and material-ui with flask backend?
I am a beginner with react. I was just trying to make a web app with flask backend and react frontend with material-ui but I was facing problems with setting it up.
What I did
I downloaded the React Scripts from here. Then the material-ui from CDN…

Jalaj
- 463
- 3
- 16
3
votes
0 answers
Possible to create custom locale, such as fr_EN?
I am looking for a possibility to create a custom locale for my website. The website is available in several languages, including French. The French version of the website has particular content which is specific to France and not present in other…

Al Nikolaj
- 305
- 4
- 13