From 84ebb861544db4ce3fff657dd3d989f3364732a7 Mon Sep 17 00:00:00 2001 From: Tyler Kennedy Date: Thu, 27 Aug 2020 21:09:45 -0400 Subject: [PATCH] Start stripping out format_ methods. (#164) Also start working on new documentation (#173) --- docs/index.rst | 196 ++++--------------- flask_babel/__init__.py | 413 ++++------------------------------------ 2 files changed, 79 insertions(+), 530 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 442932f..8a0641c 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -3,11 +3,7 @@ Flask-Babel .. module:: flask_babel -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 :mod:`gettext` -translations. +Easy integration of `Flask`_ and `babel`_. Installation ------------ @@ -35,9 +31,9 @@ object after configuring the application:: babel = Babel(app) To disable jinja support, include ``configure_jinja=False`` in the Babel -constructor call. The babel object itself can be used to configure the babel support -further. Babel has the following configuration values that can be used to -change some internal defaults: +constructor call. The babel object itself can be used to configure the babel +support further. Babel has the following configuration values that can be used +to change some internal defaults: =============================== ============================================= `BABEL_DEFAULT_LOCALE` The default locale to use if no locale @@ -72,7 +68,7 @@ Example selector functions:: from flask import g, request @babel.localeselector - def get_locale(): + def get_user_locale(): # if a user is logged in, use the locale from the user settings user = getattr(g, 'user', None) if user is not None: @@ -83,7 +79,7 @@ Example selector functions:: return request.accept_languages.best_match(['de', 'fr', 'en']) @babel.timezoneselector - def get_timezone(): + def get_user_timezone(): user = getattr(g, 'user', None) if user is not None: return user.timezone @@ -91,122 +87,6 @@ Example selector functions:: The example above assumes that the current user is stored on the :data:`flask.g` object. -Jinja Filters -------------- - -Several commonly used formatters are added as jinja template filters after -calling `init_app().` For dates and times, these are: - -- `|datetimeformat` -> `format_datetime` -- `|dateformat` -> `format_date` -- `