O'Reilly logo

Flask Framework Cookbook by Shalabh Aggarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding a new language

By default, English is the language for applications built in Flask (and almost all web frameworks). We will add a second language to our application and add some translations for the display strings used in the application. The language displayed to the user will vary depending on the current language set in the browser.

Getting ready

We will start with the installation of the Flask-Babel extension:

$ pip install Flask-Babel

This extension uses Babel, pytz, and speaklater to add i18n and l10n support to the application.

We will use our catalog application from Chapter 5, Webforms with WTForms.

How to do it…

First, we will start with the configuration part by creating an instance of the Babel class using the app object. We will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required