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
1
vote
1 answer
serving i18n js using babel, django, & jinja2
Using django, with jinja2 for rendering & babel for message extraction
I have some js files that need to be internationalized. I haven't been able to figure out a syntax for extracting messages from them which would also let jinja2 render them. …

fastmultiplication
- 2,951
- 1
- 31
- 39
0
votes
1 answer
How do I install Python Babel library in it's trunk version?
After hours of finding out why there are missing some documented functions in my Babel installation, I learned there are two branches of Babel development:
Babel has two separate development paths (0.9.x branch and trunk) in
parallel for about 4…

Honza Javorek
- 8,566
- 8
- 47
- 66
0
votes
1 answer
Combining Eel, Jinja2, Babel - how to?
On a project where I use Eel Python and you can tell Eel to use Jinja2.
Works fine (congrats to the creators). I installed Babel, created a /lang/ folder where I store .pot and .po and .mo files after extraction (using cli command, pybabel…
0
votes
1 answer
AttributeError: module 'babel' has no attribute 'numbers'
Goal: Pass a locale code and retrieve a currency symbol.
My approach is to use babel library. However, I encounter an AttributeError in version 2.12.1.
Documentation | PDF page number: 82
Code:
import babel
def get_currency_symbol(locale_code):
…

DanielBell99
- 896
- 5
- 25
- 57
0
votes
0 answers
Flask pybabel with SubmitField not allowing spaces in string
I have a pretty complex Flask site using Babel for multilanguage support in templates using {{_('sometext')} It all works well except the buttons which truncate with any spaces in the string.
Example
{{ _("Hello World") }}
…
Bill
- 618
- 6
- 15
0
votes
1 answer
Is there a way to replace jinja2.ext.autoescape and jinja2.ext.with_ in Flask Babel?
I'm using Flask Babel for web translation:
When I write my config file like the following, it doesn't find any translations and the error is that jinja2.ext.autoescape and jinja2.ext.with_ are deprecated.
babel.cfg
[python: **.py]
[jinja2:…
0
votes
0 answers
failed to excute due to unhandled exception no module named babel.numbers
i built a python app with tkinter and i want to make it into an exe so i can use it as a normal app. the problem is pyinstaller is always throwing weird errors (i don't know if this has to do with windows 11 because in windows 10 i wasn't getting…

Milad Bannourah
- 13
- 3
0
votes
0 answers
getting time clock error while installing chatterbot
I am using bot = ChatBot(name='pybot',read_only = True,Logic_adapters = ['chatterbot.logic.MathematicalEvolutions','chatterbot.logic.BestMatch'])
but I am getting
error ERROR: Could not build wheels for srsly, which is required to install…
0
votes
1 answer
Let Flask-Babel use default locale's msgstr if the msgstr in the requested locale is empty
We would like to use Flask-Babel for the internationalizing of our Flask application.
Our goal is to use a unique ID string like "example_demo_text" for msgid and translate this msgid in several languages. Our process works like this: use the unique…

HaKePlan
- 25
- 1
- 1
- 7
0
votes
1 answer
xgettext fails to extract tag attributes
I'm stuck with xgettext missing tag attributes in HTML templates, e.g.:
xgettext --keyword=_ --language=Python -o - - <
% msg = _('A translatable string')
{{ _('Page title') }}
…

neurino
- 11,500
- 2
- 40
- 63
0
votes
2 answers
Flask Babel RuntimeError: Working outside of request context
I tried to set up multiple Dash Apps inside a Flask App and use Flask Babel.
from flask import Flask, request
from flask_babel import Babel, gettext
from werkzeug.middleware.dispatcher import DispatcherMiddleware
def init_app():
"""Construct…

ukena
- 3
- 2
0
votes
2 answers
How to translate .po file
I have a flask app and i wanted to add multiple languages to it. So i have using this demo on Flask_babel to do this.
Flask Label Demo
config.py
DEBUG = True
LANGUAGES = ['en', 'de', 'fr']
This is the app.py
from flask import Flask, request, g
from…

Aarushi
- 544
- 1
- 5
- 15
0
votes
1 answer
How do get python to output _("95% confidence interval") correctly?
I have a very frustrating issue. I need the string "95% confidence interval" to appear on in a web view. And I need to have it translatable (using babel) so I'm using it like this:
_("95% confidence interval")
When I do this it treats % c as %c and…

Cole
- 19
- 4
0
votes
2 answers
Format float to currency using PySpark and Babel
I'd like to convert a float to a currency using Babel and PySpark
sample data:
amount currency
2129.9 RON
1700 EUR
1268 GBP
741.2 USD
142.08091153 EUR
4.7E7 USD
0 GBP
I tried:
df =…

John Doe
- 9,843
- 13
- 42
- 73
0
votes
1 answer
How to set use_locale on Flaks wtform DecimalField?
I've been trying to set 'use_locale' parameter for wtform DecimalField, but nothing seems to work and there's barely any examples on how to set 'use_locale'. I've been through the documentation from both Babel and WTForm DecimalField and i got…

Max Scola
- 23
- 5