Questions tagged [flask-babel]

Flask-Babel is an extension to Flask that adds i18n and l10n support to any Flask application.

Flask-Babel is an extension to Flask that adds i18n and l10n support to any Flask application with the help of babel, pytz and speaklater.

It has builtin support for date formatting with timezone support as well as a very simple and friendly interface to gettext translations.

77 questions
14
votes
1 answer

Flask-Babel how to use translation in Jinja template file

In my Flask application, in main.py file, I defined: from flaskext.babel import gettext .... def somefun(): return render_template('some.html', messages=messages) in template file some.html, I used: python
Brent Jiang
  • 377
  • 1
  • 2
  • 11
11
votes
1 answer

Access a Flask extension that is defined in the app factory

I am using the app factory pattern to set up my Flask application. My app uses the Flask-Babel extension, and that is set up in the factory as well. However, I want to access the extension in a blueprint in order to use it, The factory is in…
Tinker
  • 4,165
  • 6
  • 33
  • 72
10
votes
2 answers

translating strings from database flask-babel

I'm using Flask-Babel for translating string. In some templates I'm reading the strings from the database(postgresql). How can I translate the strings from the database using Flask-Babel?
gulic
  • 123
  • 5
8
votes
3 answers

Flask babel not working on simple translation?

Ok I have the following app: babel.cfg [python: **.py] [jinja2: **/templates/**.html] extensions=jinja2.ext.autoescape,jinja2.ext.with_ lucy/init.py babel = Babel() def create_app(object_name): app = Flask(__name__) …
Tinker
  • 4,165
  • 6
  • 33
  • 72
7
votes
4 answers

Change Flask-Babel locale outside of request context for scheduled tasks

I run a job every hour that can send an email to users. When the email is sent, it needs to be in the language set by the user (saved in the db). I can't figure out a way to set a different locale outside of a request context. Here is what I would…
mickael
  • 315
  • 4
  • 9
7
votes
1 answer

Flask-Babel updating of existing messages.pot file

How to update an existing messages.pot file? For example, I have translated messages.pot file: .... #: forms.py:11 msgid "Nickname" msgstr "Имя" #: forms.py:18 msgid "Wrong email" msgstr "Неправильный пароль" .... If I'll mark new text with…
user2782936
  • 133
  • 1
  • 5
6
votes
0 answers

Flask Babelex 0.9.4 and % escaping

In a Flask application we recently upgraded Werkzeug to 1.0.1 (so we could set the same site on cookies), which forced a few dependencies, among which Flask-BabelEx==0.9.4. After this upgrade, the handling of escaped % (percent signs) changed in a…
patb
  • 1,688
  • 1
  • 17
  • 21
6
votes
0 answers

Flask-Babel Choose right locale using Accept-Language header

Say I have an application with a few translations available: AVAILABLE_LOCALES = ['en_US', 'en_EN', 'de_AT'] and I'd like to select the most appropriate according to the Accept-Language header.  Using request.accept_languages.best_match To get the…
Jérôme
  • 13,328
  • 7
  • 56
  • 106
5
votes
1 answer

Unit testing Flask Babel translations

I'd like to do some unit tests to check my flask app translations. I have tried this piece of code: def test_pt_br(self): with app.test_request_context(): app.config['BABEL_DEFAULT_LOCALE'] = 'pt_BR' rv =…
andref
  • 750
  • 5
  • 20
5
votes
3 answers

Flask Babel Translations path

I have a webapp that uses Flask Babel to translate the templates. This webapp can use multiple databases by adding the database name to its url, like: myapp.com/ The problem is that translations path is hardcoded in babel: def…
xyro
  • 465
  • 1
  • 6
  • 25
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
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
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

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
3
votes
1 answer

Localization in a Microservices based webapp

We are currently in the process of adding localization to our system and I am trying to figure out what is the favorable option for that challenge. My system is a Microservice python based architecture web application. FE communicates with multiple…
1
2 3 4 5 6