Lazy evaluation and the gettext/ngettext functions

Lazy evaluation is an evaluation strategy that delays the evaluation of an expression until its value is needed, that is, it is a call-by-need mechanism. In our application, there can be several instances of texts that are evaluated later while rendering the template. It usually happens when we have texts that are marked as translatable outside the request context, so we defer the evaluation of these until they are actually needed.

Getting ready

Let's start with the application from the previous recipe. Now, we want the labels in the product- and category-creation forms to show the translated values.

How to do it…

To mark all the field labels in the product and category forms as translatable, we will ...

Get Flask Framework Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.