Metadata-Version: 2.1
Name: starlette-i18n
Version: 0.3.0
Summary: Localisation helper for starlette
Home-page: https://github.com/bigbag/starlette-i18n
Author: Pavel Liashkov
Author-email: pavel.liashkov@protonmail.com
Maintainer: Pavel Liashkov
Maintainer-email: pavel.liashkov@protonmail.com
License: Apache License, Version 2.0
Download-URL: https://pypi.python.org/pypi/starlette-i18n
Description: starlette-i18n
        =======================================================================
        
        .. image:: https://github.com/bigbag/starlette-i18n/workflows/CI/badge.svg
           :target: https://github.com/bigbag/starlette-i18n/actions?query=workflow%3ACI
        .. image:: https://img.shields.io/pypi/v/starlette-i18n.svg
           :target: https://pypi.python.org/pypi/starlette-i18n
        
        
        **starlette-i18n** is a localisation helper for starlette.
        
        
        Installation
        ------------
        starlette-i18n is available on PyPI.
        Use pip to install:
        
            $ pip install starlette-i18n
        
        Basic Usage
        -----------
        
        .. code:: python
        
            import uvicorn
            from starlette.applications import Starlette
            from starlette.responses import PlainTextResponse
        
            from starlette_i18n import (
                DEFAULT_LOCALE,
                LANGUAGE_HEADER,
                LocaleMiddleware,
                load_gettext_translations,
            )
        
            BABEL_DOMAIN = "messages"
            BABEL_LOCALES_PATH = "locales"
        
        
            def init_app():
                load_gettext_translations(directory=BABEL_LOCALES_PATH, domain=BABEL_DOMAIN)
        
                app_ = Starlette()
                app_.add_middleware(
                    LocaleMiddleware, language_header=LANGUAGE_HEADER, default_code=DEFAULT_LOCALE
                )
        
                @app_.route("/")
                def success(request):
                    return PlainTextResponse("OK", status_code=200)
        
                return app_
        
        
            app = init_app()
        
            if __name__ == "__main__":
                uvicorn.run(app=app)
        
        
        License
        -------
        
        starlette-i18n is developed and distributed under the Apache 2.0 license.
Platform: POSIX
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Operating System :: POSIX
Classifier: Topic :: System :: Networking
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Requires-Python: >=3.7
Description-Content-Type: text/x-rst
