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

How to use translation in Flask?

I have an application in which I have managed to use translations for romanian and english. I want to press the button "english" and get the website translated in english and when pressing "romanian" the website should translate to romanian. I have…
moro_922
  • 113
  • 8
0
votes
1 answer

Flask Babel convert to original language when insert to database

I have a set of SelectField with Flask-WTF and I convert the default language with Flask-Babel. Here is the snippet of my code: from flask_babel import _, lazy_gettext as _l class PaymentStatus(enum.Enum): PENDING = _l('PENDING') COMPLETED…
Tri
  • 2,722
  • 5
  • 36
  • 65
0
votes
0 answers

How can I format a date within a longer string in a Jinja template with flask_babel?

Within a jinja template, I have the following string # English

by John Smith on

# German

am

Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
0
votes
1 answer

serverless-python-requirements throwing an error unable to link babel

I recently added flash babel to my serverless flask app and everything works when I run things locally with sls wsgi serve. But when I run a serverless deploy, the packaging step is failing with the below message: Unable to link dependency 'babel'…
sethu
  • 8,181
  • 7
  • 39
  • 65
0
votes
1 answer

Flask App not calling Babel localeselector

I am adding localisation to my Flask app with Flask-Babel, and I cannot seem to change the language. I followed all the Babel instructions for creating the po/mo files - I don't believe my issue is related to the translation data... its that I…
user9277612
  • 497
  • 4
  • 14
0
votes
0 answers

@babel.localselector not called

I have a problem using Flask Babel and python3.6. My code is as following: @babel.localeselector def get_locale(): lang_supported = app.config.get('LANGUAGES', []) lang = request.accept_languages.best_match(lang_supported.keys()) …
maltere
  • 41
  • 6
0
votes
1 answer

Flask-Babel not working on the login page

I have a Flask/Dash app that uses the Flask-Babel module. The translation works like a charm after logging in and browsing through pages. However, I cannot make it work for the login page which will always be displayed in English. The messages.po…
arudzinska
  • 3,152
  • 1
  • 16
  • 29
0
votes
1 answer

How to use Flask-Babel to localise data returned by QuerySelectField in a flask_wtf

I would like to use Flask-Babel to localise content in the app. Now I understand how Flask-Babel works and it's used to localise static content. I have created a number of forms using Flask-wtf and they use QuerySelectField to fetch data from the…
avizzzy
  • 440
  • 9
  • 21
0
votes
1 answer

Translate elements from list in Jinja2 template using Flask-Babel

I have a Jinja2 template that the menu items are defined in a Jinja2 list like this: {% set nav = [ ('Foo', 'user.foo'), ('Bar', 'user.bar'), ] %} Later in the template I have a for loop: {% for title, endpoint in nav %} {% if endpoint ==…
Vasko
  • 343
  • 1
  • 4
  • 9
0
votes
1 answer

flask babel doesn't work with string returned by view

Sorry, I'm new on flask-babel, and also on flask! My flask code: test.py app = Flask(__name__) app.config['BABEL_DEFAULT_LOCALE'] = 'en' babel = Babel(app) @app.route('/', methods=['GET']) def hello_world(): message = _(u'测试 页面') return…
Derek Kuo
  • 33
  • 6
0
votes
1 answer

Flask Babel: adding pycountry external locale

I am trying to add an external locale directory from the pycountry package. Before initializing Flask Babel, I do the following: import pycountry app.config['BABEL_TRANSLATION_DIRECTORIES'] = 'translations;' + pycountry.LOCALES_DIR But alas, this…
Ricardo Magalhães Cruz
  • 3,504
  • 6
  • 33
  • 57
0
votes
2 answers

Flask babel: flask-table is not translated

I'm trying to translate a flask web project with babel (using Ubuntu 16.04/python 2.7.12). Everything seems to work fine, except for the tables. The names of the columns just won't be translated. Does anyone know how I get that to work? My .py…
Rena
  • 31
  • 2
  • 9
0
votes
1 answer
0
votes
1 answer

Keep header in messages.pot using Flask-Babel pybabel extract

Is it possible to keep/set the header in the messages.pot, between execution? I found three options to control the header. But there is more info I would like to keep/set, like project name/version etc.…
Arlukin
  • 319
  • 1
  • 3
  • 12
0
votes
1 answer

Flask Bable - [jinja2: **/templates/**.html] SyntaxError: invalid syntax

I find the documentation between Flask Babel and Jinja confusing. ubuntu@ubuntu-VirtualBox:~/workspace/rtbopsConfig/rtbDashboard3$ python run.py Traceback (most recent call last): File "run.py", line 11, in from app import app File…
Tampa
  • 75,446
  • 119
  • 278
  • 425