Locale#
- quart_babel.get_locale() Locale | None#
Gets the current active locale from context.
- quart_babel.switch_locale(locale: str) Generator[None, None, None]#
Temporary switch current locale for a code block. The previous locale will be restored after exiting the manager.
- Use example:
- with switch_locale(‘en-US’):
end_email(gettext(‘Hello!’), …)
- Parameters:
locale – The locale to temporary switch to (ex: ‘en_US’).
- quart_babel.refresh_locale(locale: str | None = None) None#
Refreshes the cached locale information. This can be used to switch a translation between a request and if you want the changes to take place immediately, not just with the next request.
Arguments: locale: The locale to set. If none is used it will use the default locale.
- async quart_babel.select_locale_by_request(request: Request) str | None#
Gets the users locale by a given request.
- Parameters:
request – The ASGI Request object.