{ "info": { "author": "Romain Clement", "author_email": "r.clement88@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Flask-Language\n==============\n\n|PyPI Version| |PyPI License| |PyPI Versions| |Build Status| |Coverage\nStatus| |Documentation Status|\n\nFlask-Language is a Flask_ extension providing a\nsimple mechanism to handle a client-side language cookie.\n\nIt is somewhat loosely based on this snippet: ``__\n\n.. _Flask: http://flask.pocoo.org\n\nInstallation\n------------\n\nInstall the extension with with pipenv_ (recommended):\n\n::\n\n $ pipenv install flask-language\n\nOr with pip_:\n\n::\n\n $ pip install flask-language\n\n.. _pip: https://pip.pypa.io\n.. _pipenv: https://docs.pipenv.org\n\nUsage\n-----\n\nInitialize the Flask-Language extension (also compatible with the `Application Factories`_ pattern):\n\n::\n\n from flask import Flask, jsonify\n from flask_language import Language, current_language\n\n app = Flask(__name__)\n lang = Language(app)\n\nDefine the language hooks:\n\n::\n\n @lang.allowed_languages\n def get_allowed_languages():\n return ['en', 'fr']\n\n @lang.default_language\n def get_default_language():\n return 'en'\n\nDefine the desired end-points to retrieve and manipulate the current language:\n\n::\n\n @app.route('/api/language')\n def get_language():\n return jsonify({\n 'language': str(current_language),\n })\n\n @app.route('/api/language', methods=['POST'])\n def set_language():\n req = request.get_json()\n language = req.get('language', None)\n\n lang.change_language(language)\n\n return jsonify({\n 'language': str(current_language),\n })\n\nBefore each request, Flask-Language will automatically determine the current\nlanguage in the following order:\n\n1. The language cookie (if any and matching the allowed languages)\n2. The ``Accept-Language`` HTTP header (if any and matching the allowed languages)\n3. The provided default language\n\nDuring each request context, the current language can be accessed using\n``current_language``.\n\nAfter each request, the current language will be stored in the language cookie.\n\n.. _Application Factories: http://flask.pocoo.org/docs/0.12/patterns/appfactories/\n\nConfiguration\n-------------\n\nFlask-Language is configurable via the following configuration variables:\n\n- ``LANGUAGE_COOKIE_NAME``: name for the cookie language (default: ``'lang'``)\n- ``LANGUAGE_COOKIE_TIMEOUT``: validity duration of the cookie language (default: ``datetime.timedelta(days=365)``)\n- ``LANGUAGE_COOKIE_DOMAIN``: domain for the cookie language (default: ``None``)\n- ``LANGUAGE_COOKIE_SECURE``: set secure option for the cookie language (default: ``False``)\n- ``LANGUAGE_COOKIE_HTTPONLY``: set HTTP-only for the cookie language (default: ``False``)\n\nDocumentation\n-------------\n\nThe Sphinx-compiled documentation is available on\n`ReadTheDocs `__.\n\nLicense\n-------\n\nThe MIT License (MIT)\n\nCopyright (c) 2018 Romain Clement\n\n.. |PyPI Version| image:: https://img.shields.io/pypi/v/flask-language.svg\n :target: https://pypi.python.org/pypi/flask-language\n.. |PyPI License| image:: https://img.shields.io/pypi/l/flask-language.svg\n :target: https://pypi.python.org/pypi/flask-language\n.. |PyPI Versions| image:: https://img.shields.io/pypi/pyversions/flask-language.svg\n :target: https://pypi.python.org/pypi/flask-language\n.. |Build Status| image:: https://travis-ci.org/rclement/flask-language.svg?branch=master\n :target: https://travis-ci.org/rclement/flask-language\n.. |Coverage Status| image:: https://coveralls.io/repos/github/rclement/flask-language/badge.svg?branch=master\n :target: https://coveralls.io/github/rclement/flask-language?branch=master\n.. |Documentation Status| image:: https://readthedocs.org/projects/flask-language/badge/?version=master\n :target: http://flask-language.readthedocs.io/en/master/\n\n\nRelease History\n===============\n\n0.1.0 (2018-03-07)\n------------------\n\n- Initial release of Flask-Language\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/rclement/flask-language", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "Flask-Language", "package_url": "https://pypi.org/project/Flask-Language/", "platform": "any", "project_url": "https://pypi.org/project/Flask-Language/", "project_urls": { "Homepage": "https://github.com/rclement/flask-language" }, "release_url": "https://pypi.org/project/Flask-Language/0.1.0/", "requires_dist": null, "requires_python": "", "summary": "Flask extension handling client-side language cookie", "version": "0.1.0" }, "last_serial": 3650724, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "cfce48a5bce81b5c23def63a04213157", "sha256": "ff843fe5ff16095bc99923ecd958005fe52e743584e1679a3af95d7ee11b3736" }, "downloads": -1, "filename": "Flask-Language-0.1.0.tar.gz", "has_sig": false, "md5_digest": "cfce48a5bce81b5c23def63a04213157", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9182, "upload_time": "2018-03-08T10:15:34", "url": "https://files.pythonhosted.org/packages/a6/08/e6ebf39e488ad5bc72f8f65a069b5bc9ce3f02cbb3a8cf364d0f62c9eca7/Flask-Language-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cfce48a5bce81b5c23def63a04213157", "sha256": "ff843fe5ff16095bc99923ecd958005fe52e743584e1679a3af95d7ee11b3736" }, "downloads": -1, "filename": "Flask-Language-0.1.0.tar.gz", "has_sig": false, "md5_digest": "cfce48a5bce81b5c23def63a04213157", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9182, "upload_time": "2018-03-08T10:15:34", "url": "https://files.pythonhosted.org/packages/a6/08/e6ebf39e488ad5bc72f8f65a069b5bc9ce3f02cbb3a8cf364d0f62c9eca7/Flask-Language-0.1.0.tar.gz" } ] }