././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1598498051.856946 Flask-Babel-2.0.0/0000755000175100001640000000000000000000000014356 5ustar00runnerdocker00000000000000././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1598498051.852946 Flask-Babel-2.0.0/Flask_Babel.egg-info/0000755000175100001640000000000000000000000020175 5ustar00runnerdocker00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498051.0 Flask-Babel-2.0.0/Flask_Babel.egg-info/PKG-INFO0000644000175100001640000000361100000000000021273 0ustar00runnerdocker00000000000000Metadata-Version: 2.1 Name: Flask-Babel Version: 2.0.0 Summary: Adds i18n/l10n support to Flask applications Home-page: http://github.com/python-babel/flask-babel Author: Armin Ronacher Author-email: armin.ronacher@active-4.com Maintainer: Tyler Kennedy Maintainer-email: tk@tkte.ch License: BSD Description: # Flask Babel ![Tests](https://github.com/python-babel/flask-babel/workflows/Tests/badge.svg?branch=master) [![PyPI](https://img.shields.io/pypi/v/flask-babel.svg?maxAge=2592000)](https://pypi.python.org/pypi/Flask-Babel) Implements i18n and l10n support for Flask. This is based on the Python [babel][] module as well as [pytz][] both of which are installed automatically for you if you install this library. # Documention The latest documentation is available [here][docs]. [babel]: https://github.com/python-babel/babel [pytz]: https://pypi.python.org/pypi/pytz/ [docs]: https://flask-babel.tkte.ch/ [semver]: https://semver.org/ Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content Classifier: Topic :: Software Development :: Libraries :: Python Modules Description-Content-Type: text/markdown Provides-Extra: dev ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498051.0 Flask-Babel-2.0.0/Flask_Babel.egg-info/SOURCES.txt0000644000175100001640000000211600000000000022061 0ustar00runnerdocker00000000000000LICENSE MANIFEST.in README.md setup.py Flask_Babel.egg-info/PKG-INFO Flask_Babel.egg-info/SOURCES.txt Flask_Babel.egg-info/dependency_links.txt Flask_Babel.egg-info/not-zip-safe Flask_Babel.egg-info/requires.txt Flask_Babel.egg-info/top_level.txt docs/Makefile docs/conf.py docs/index.rst docs/make.bat flask_babel/__init__.py flask_babel/speaklater.py tests/babel.cfg tests/test_date_formatting.py tests/test_gettext.py tests/test_integration.py tests/test_number_formatting.py tests/renamed_translations/messages.pot tests/renamed_translations/de/LC_MESSAGES/messages.mo tests/renamed_translations/de/LC_MESSAGES/messages.po tests/renamed_translations/de/LC_MESSAGES/myapp.mo tests/renamed_translations/de/LC_MESSAGES/myapp.po tests/translations/messages.pot tests/translations/de/LC_MESSAGES/messages.mo tests/translations/de/LC_MESSAGES/messages.po tests/translations/de/LC_MESSAGES/test.mo tests/translations/de/LC_MESSAGES/test.po tests/translations_different_domain/myapp.pot tests/translations_different_domain/de/LC_MESSAGES/myapp.mo tests/translations_different_domain/de/LC_MESSAGES/myapp.po././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498051.0 Flask-Babel-2.0.0/Flask_Babel.egg-info/dependency_links.txt0000644000175100001640000000000100000000000024243 0ustar00runnerdocker00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498051.0 Flask-Babel-2.0.0/Flask_Babel.egg-info/not-zip-safe0000644000175100001640000000000100000000000022423 0ustar00runnerdocker00000000000000 ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498051.0 Flask-Babel-2.0.0/Flask_Babel.egg-info/requires.txt0000644000175100001640000000016000000000000022572 0ustar00runnerdocker00000000000000pytz Flask Babel>=2.3 Jinja2>=2.5 [dev] pytest pytest-mock bumpversion ghp-import sphinx Pallets-Sphinx-Themes ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498051.0 Flask-Babel-2.0.0/Flask_Babel.egg-info/top_level.txt0000644000175100001640000000001400000000000022722 0ustar00runnerdocker00000000000000flask_babel ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498042.0 Flask-Babel-2.0.0/LICENSE0000644000175100001640000000266100000000000015370 0ustar00runnerdocker00000000000000Copyright (c) 2010 by Armin Ronacher. Some rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498042.0 Flask-Babel-2.0.0/MANIFEST.in0000644000175100001640000000036600000000000016121 0ustar00runnerdocker00000000000000include Makefile LICENSE README.md recursive-include tests * recursive-exclude tests *.pyc recursive-exclude tests *.pyo recursive-include docs * recursive-exclude docs *.pyc recursive-exclude docs *.pyo prune docs/_build prune docs/_themes/.git ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1598498051.856946 Flask-Babel-2.0.0/PKG-INFO0000644000175100001640000000361100000000000015454 0ustar00runnerdocker00000000000000Metadata-Version: 2.1 Name: Flask-Babel Version: 2.0.0 Summary: Adds i18n/l10n support to Flask applications Home-page: http://github.com/python-babel/flask-babel Author: Armin Ronacher Author-email: armin.ronacher@active-4.com Maintainer: Tyler Kennedy Maintainer-email: tk@tkte.ch License: BSD Description: # Flask Babel ![Tests](https://github.com/python-babel/flask-babel/workflows/Tests/badge.svg?branch=master) [![PyPI](https://img.shields.io/pypi/v/flask-babel.svg?maxAge=2592000)](https://pypi.python.org/pypi/Flask-Babel) Implements i18n and l10n support for Flask. This is based on the Python [babel][] module as well as [pytz][] both of which are installed automatically for you if you install this library. # Documention The latest documentation is available [here][docs]. [babel]: https://github.com/python-babel/babel [pytz]: https://pypi.python.org/pypi/pytz/ [docs]: https://flask-babel.tkte.ch/ [semver]: https://semver.org/ Platform: UNKNOWN Classifier: Development Status :: 5 - Production/Stable Classifier: Environment :: Web Environment Classifier: Intended Audience :: Developers Classifier: License :: OSI Approved :: BSD License Classifier: Operating System :: OS Independent Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content Classifier: Topic :: Software Development :: Libraries :: Python Modules Description-Content-Type: text/markdown Provides-Extra: dev ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498042.0 Flask-Babel-2.0.0/README.md0000644000175100001640000000117700000000000015643 0ustar00runnerdocker00000000000000# Flask Babel ![Tests](https://github.com/python-babel/flask-babel/workflows/Tests/badge.svg?branch=master) [![PyPI](https://img.shields.io/pypi/v/flask-babel.svg?maxAge=2592000)](https://pypi.python.org/pypi/Flask-Babel) Implements i18n and l10n support for Flask. This is based on the Python [babel][] module as well as [pytz][] both of which are installed automatically for you if you install this library. # Documention The latest documentation is available [here][docs]. [babel]: https://github.com/python-babel/babel [pytz]: https://pypi.python.org/pypi/pytz/ [docs]: https://flask-babel.tkte.ch/ [semver]: https://semver.org/ ././@PaxHeader0000000000000000000000000000003300000000000011451 xustar000000000000000027 mtime=1598498051.852946 Flask-Babel-2.0.0/docs/0000755000175100001640000000000000000000000015306 5ustar00runnerdocker00000000000000././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498042.0 Flask-Babel-2.0.0/docs/Makefile0000644000175100001640000000127400000000000016752 0ustar00runnerdocker00000000000000# Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) import: ghp-import -n -c flask-babel.tkte.ch "$(BUILDDIR)/html" .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498042.0 Flask-Babel-2.0.0/docs/conf.py0000644000175100001640000000373200000000000016612 0ustar00runnerdocker00000000000000# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # import os # import sys # sys.path.insert(0, os.path.abspath('.')) # -- Project information ----------------------------------------------------- project = 'Flask-Babel' copyright = '2020, Armin Ronacher' author = 'Armin Ronacher' # The full version, including alpha/beta/rc tags release = '2.0.0' # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'pallets_sphinx_themes' ] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] # -- Options for HTML output ------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # html_theme = 'flask' # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ['_static'] ././@PaxHeader0000000000000000000000000000002600000000000011453 xustar000000000000000022 mtime=1598498042.0 Flask-Babel-2.0.0/docs/index.rst0000644000175100001640000002755300000000000017163 0ustar00runnerdocker00000000000000Flask-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. Installation ------------ Install the extension from PyPi:: $ pip install Flask-Babel Please note that Flask-Babel requires Jinja >=2.5. If you are using an older version you will have to upgrade or disable the Jinja support (see configuration). Configuration ------------- To get started all you need to do is to instantiate a :class:`Babel` object after configuring the application:: from flask import Flask from flask_babel import Babel app = Flask(__name__) app.config.from_pyfile('mysettings.cfg') 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: =============================== ============================================= `BABEL_DEFAULT_LOCALE` The default locale to use if no locale selector is registered. This defaults to ``'en'``. `BABEL_DEFAULT_TIMEZONE` The timezone to use for user facing dates. This defaults to ``'UTC'`` which also is the timezone your application must use internally. `BABEL_TRANSLATION_DIRECTORIES` A semi-colon (``;``) separated string of absolute and relative (to the `root_path` of the application object) paths to translation folders. Defaults to ``translations``. `BABEL_DOMAIN` The message domain used by the application. Defaults to ``messages``. =============================== ============================================= For more complex applications you might want to have multiple applications for different users which is where selector functions come in handy. The first time the babel extension needs the locale (locale code/ID) of the current user it will call a :meth:`~Babel.localeselector` function, and the first time the timezone is needed it will call a :meth:`~Babel.timezoneselector` function. If any of these methods return `None` the extension will automatically fall back to what's in the config. Furthermore for efficiency that function is called only once and the return value then cached. If you need to switch the language between a request, you can :func:`refresh` the cache. Example selector functions:: from flask import g, request @babel.localeselector def get_locale(): # if a user is logged in, use the locale from the user settings user = getattr(g, 'user', None) if user is not None: return user.locale # otherwise try to guess the language from the user accept # header the browser transmits. We support de/fr/en in this # example. The best match wins. return request.accept_languages.best_match(['de', 'fr', 'en']) @babel.timezoneselector def get_timezone(): user = getattr(g, 'user', None) if user is not None: return user.timezone 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` - `