{ "info": { "author": "Christopher Grebs", "author_email": "cg@webshox.org", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Tools for using Babel with Django\n=================================\n\nThis package contains various utilities for integration of `Babel`_ into the\n`Django`_ web framework:\n\n * A message extraction plugin for Django templates.\n * A middleware class that adds the Babel `Locale`_ object to requests.\n * A set of template tags for date and number formatting.\n\n\nExtracting Messages\n-------------------\n\nBabel provides a message extraction framework similar to GNU ``xgettext``, but\nmore extensible and geared towards Python applications. While Django does\nprovide `wrapper scripts`_ for making the use of ``xgettext`` more\nconvenient, the extraction functionality is rather limited. For example, you\ncan't use template files with an extension other than ``.html``, and everything\nneeds to be in your project package directory.\n\nExtraction Method Mapping\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\nSo enmerkar comes with an extraction method plugin that can extract\nlocalizable messages from Django template files. Python is supported out of the\nbox by Babel. To use this extraction functionality, create a file called\n``babel.cfg`` in your project directory (the directory above your project\npackage), with the content:\n\n.. code-block:: ini\n\n [django: templates/**.*]\n [django: mypkg/*/templates/**.*]\n [python: mypkg/**.py]\n\nThis instructs Babel to look for any files in the top-level ``templates``\ndirectory, or any files in application ``templates`` directories, and use the\nextraction method named \u201cdjango\u201d to extract messages from those template files.\nYou'll need to adjust those glob patterns to wherever you my be storing your\ntemplates.\n\nAlso, any files with the extension ``.py`` inside your package directory (replace\n\u201cmypkg\u201d with the actual name of your Django project package) are processed by\nthe \u201cpython\u201d extraction method.\n\nIf you don't use setuptools, or for some reason haven't installed enmerkar\nusing setuptools/pip, you'll need to define what function the extraction method\n\u201cdjango\u201d maps to. This is done in an extra section at the top of the\nconfiguration file:\n\n.. code-block:: ini\n\n [extractors]\n django = enmerkar.extract:extract_django\n\nThe encoding of the templates is assumed to be UTF-8. If you are using a\ndifferent encoding, you will need to specify it in the configuration. For\nexample:\n\n.. code-block:: ini\n\n [django: templates/**.*]\n encoding = iso-8859-1\n\n\nRunning the Extraction Process\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nOnce you've set up the configuration file, the actual extraction is performed\nby executing the command-line program ``pybabel`` which is installed alongside\nthe Babel package:\n\n.. code-block:: bash\n\n $ cd projectdir\n $ pybabel extract -F babel.cfg -o mypkg/locale/django.pot .\n\nThis creates the PO file template in ``mypkg/locale/django.pot``.\n\n\nCreating and Updating Translations Catalogs\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nIf you don't already have translation catalogs, you need to create them. This\nis done using the ``pybabel init`` command:\n\n.. code-block:: bash\n\n $ pybabel init -D django -i mypkg/locale/django.pot -d mypkg/locale -l en_US\n $ pybabel init -D django -i mypkg/locale/django.pot -d mypkg/locale -l de_DE\n\nThis should create two files: ``mypkg/locale/en_US/django.po`` and\n``mypkg/locale/de_DE/django.po``. These files are where you put the actual\ntranslations.\n\nWhen you modify your Python source files or your templates, you genereally need\nto sync the translation catalogs. For that, you first perform a fresh\nextraction as described in the previous section, so that the ``django.pot`` file\ngets updated.\n\nThen, you run the ``pybabel update`` command to merge the changes into the\ntranslation catalogs:\n\n```bash\n$ pybabel update -D django -i mypkg/locale/django.pot -d mypkg/locale\n```\n\nThis will update all the ``.po`` files found in the ``mypkg/locale`` directory.\n\n\nCompiling Translations Catalogs\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nFinally, you need to compile those ``.po`` files to binary ``.mo`` files. Use the\n`pybabel compile` command for that:\n\n.. code-block:: bash\n\n $ pybabel compile -D django -d mypkg/locale\n\nAdd the ``--statistics`` option to get information about the completeness of your\ntranslations:\n\n.. code-block:: bash\n\n $ pybabel compile -D django -d mypkg/locale --statistics\n\n\nUsing ``setup.py``\n^^^^^^^^^^^^^^^^^^\n\nMuch of the above process can be automated if you add a ``setup.py`` script to\nyour project and use the distutils/setuptools commands that come with Babel.\nThis is described at `Distutils/Setuptools Integration`_.\n\n\nUsing the Middleware\n--------------------\n\nTo use the enmerkar middleware, add it to the list of ``MIDDLEWARE_CLASSES`` in your\nsettings module. If you're also using Django's own ``LocaleMiddleware`` to vary\nthe locale based on user preference, the enmerkar middleware must be inserted\nafter the Django one:\n\n.. code-block:: python\n\n MIDDLEWARE_CLASSES = (\n ...\n 'django.middleware.locale.LocaleMiddleware',\n 'enmerkar.middleware.LocaleMiddleware',\n ...\n )\n\nThis adds a ``locale`` attribute to the request object, which is an instance of\nthe Babel ``Locale`` class. You can access the locale via ``request.locale`` when\nthe request object is available, or otherwise use the\n``django_babel.middleware.get_current_locale()`` function to get the current\nlocale from a thread-local cache.\n\n\nUsing the Template Tags\n-----------------------\n\nThe template filters provided by enmerkar allow formatting of date/time and\nnumber values in a locale-sensitive manner, providing much more powerful\nalternatives to the ``date``, ``time``, and ``floatformat`` filters that come with\nDjango.\n\nTo make the template filters/tags available, you need to add enmerkar to\nthe list of ``INSTALLED_APPS`` in your settings module:\n\n.. code-block:: python\n\n INSTALLED_APPS = (\n ...\n 'enmerkar',\n ...\n )\n\nAnd in every template you want to use the filters, you need to explicitly load\nthe library:\n\n.. code-block:: django\n\n {% load babel %}\n\nGeneral information on date/time and number formatting can be found at\n`Date Formatting`_ and `Number Formatting`_.\n\nThe following filters are made available. The examples assume a locale of\n``en_US``.\n\n\n``datefmt``\n^^^^^^^^^^^\n\nRenders a string representation of a date.\n\n* **Input**: ``datetime.date``, ``datetime.datetime``, or a float/int timestamp\n* **Parameters**: the format name or pattern (optional)\n\nAssuming that ``book.pubdate`` returns a ``datetime.date`` or\n``datetime.datetime`` object:\n\n.. code-block:: django\n\n {{ book.pubdate|datefmt:\"short\" }}\n\nwould render: **4/1/07**, and\n\n.. code-block:: django\n\n {{ book.pubdate|datefmt:\"E, MMM dd yyyy GGG\" }}\n\nwould render: **Sun, Apr 01 2007 AD**\n\n``datetimefmt``\n^^^^^^^^^^^^^^^\n\nRenders a string representation of a date and time.\n\n* **Input**: ``datetime.datetime``, or a float/int timestamp\n* **Parameters**: the format name or pattern (optional)\n\nExamples:\n\n.. code-block:: django\n\n {{ book.pubdate|datetimefmt:\"short\" }}\n\nwould render: **4/1/07 3:30 PM**, and\n\n.. code-block:: django\n\n {{ book.pubdate|datetimefmt:\"E, MMM dd yyyy GGG' - 'HH:mm:ss'\" }}\n\nwould render: **Sun, Apr 01 2007 AD - 15:30:00**\n\n``timefmt``\n^^^^^^^^^^^\n\nRenders a string representation of a time.\n\n* **Input**: ``datetime.datetime``, ``datetime.time``, or a float/int timestamp\n* **Parameters**: the format name or pattern (optional)\n\nExamples:\n\n.. code-block:: django\n\n {{ book.pubdate|timefmt:\"short\" }}\n\nwould render: **3:30 PM**, and\n\n.. code-block:: django\n\n {{ book.pubdate|timefmt:\"h 'o''clock' a'\" }}\n\nwould render: **3 o'clock PM**\n\n``decimalfmt``\n^^^^^^^^^^^^^^\n\nRenders a string representation of a decimal number.\n\n* **Input**: a `Decimal` object, or a float/int/long value\n* **Parameters**: the format name or pattern (optional)\n\nExamples:\n\n.. code-block:: django\n\n {{ book.pagecount|decimalfmt }}\n\nwould render: **1,234**, and\n\n.. code-block:: django\n\n {{ book.pagecount|decimalfmt:\"#,##0.00\" }}\n\nwould render: **1,234.00**\n\n``currencyfmt``\n^^^^^^^^^^^^^^^\n\nRenders a number formatted as a currency value.\n\n* **Input**: a ``Decimal`` object, or a float/int/long value\n* **Parameters**: the currency code\n\nExamples:\n\n.. code-block:: django\n\n {{ book.price|currencyfmt:\"USD\" }}\n\nwould render: **$49.90**\n\n``percentfmt``\n^^^^^^^^^^^^^^\n\nRenders a string representation of a number as a percentage.\n\n* **Input**: a ``Decimal`` object, or a float/int/long value\n* **Parameters**: the format name or pattern (optional)\n\nExamples:\n\nAssuming ``book.rebate`` would return ``0.15``,\n\n.. code-block:: django\n\n {{ book.rebate|percentfmt }}\n\nwould render **15%**, and\n\n.. code-block:: django\n\n {{ book.rebate|percentfmt:\"#,##0.00%\" }}\n\nwould render **15.00%**.\n\n``scientificfmt``\n^^^^^^^^^^^^^^^^^\n\nRenders a string representation of a number using scientific notation.\n\n* **Input**: a ``Decimal`` object, or a float/int/long value\n* **Parameters**: none\n\nExamples:\n\nAssuming ``book.numsold`` would return 1.000.000,\n\n.. code-block:: django\n\n {{ book.numsold|scientificfmt }}\n\nwould render **10E5**.\n\n\n\n.. _Babel: http://babel.pocoo.org/\n.. _Django: https://www.djangoproject.com/\n.. _wrapper scripts: https://docs.djangoproject.com/en/dev/topics/i18n/translation/#localization-how-to-create-language-files\n.. _Distutils/Setuptools Integration: http://babel.pocoo.org/en/stable/setup.html\n.. _Date Formatting: http://babel.pocoo.org/en/stable/dates.html\n.. _Number Formatting: http://babel.pocoo.org/en/stable/numbers.html\n.. _Locale: http://babel.pocoo.org/en/stable/api/core.html#babel.core.Locale\n\n\nChangelog\n=========\n\n0.7.1 (2019-12-02)\n------------------\n\n- compatibility with Django 3.0\n- drop support for Python < 3.5, Django < 2.2\n\n\n0.7.0 (2019-10-21)\n------------------\n\n- forked from django-babel\n- drop support for Python < 3.4, Django < 2.0\n- compatibility with Django 2.1 and 2.2 added\n From @tsouvarev work : https://github.com/python-babel/django-babel/pull/45\n\n0.6.2 (2017-12-18)\n------------------\n\n- compatibility with Django 2.0 added\n\n\n0.6.1 (2017-12-18)\n------------------\n\n* compatibility with Django 1.11 added\n\n0.6.0 - 2017-04-25\n------------------\n\n* compatibility with unsupported Django versions (<1.8) is dropped\n* compatibility with Django 1.10+ middlewares was added\n\n0.5.1 - 2016-03-30\n------------------\n\n* make imports absolute in babel templatetags\n* strip quotes from translations via _()\n* fix links in docs\n* Add support for \"trimmed\" blocktrans content\n\n0.5.0 - 2016-02-29\n------------------\n\n* Add compatibility for Django-1.9\n\n0.4.0 - 2015-04-22\n------------------\n\n* Add compatibility for Django 1.8\n* Add compatibility for latest django master\n* Various python 3 fixes\n\n\n0.3.9 - 2014-12-24\n------------------\n\n* Fix dependencies on Django/Babel to use lower-case egg names.\n\n0.3.8 - 2014-10-14\n------------------\n\n* Fix old reference to `babeldjango` module in entry points.\n\n0.3.7 - 2014-10-14\n------------------\n\n* Fix Python 3.x compatibility in `babel makemessages` command.\n\n0.3.6 - 2014-10-05\n------------------\n\n* Django 1.7 compatibility\n\n\n0.3.5 - 2014-09-10\n------------------\n\n* Create .po and .pot files if not existing, plus it's specific base directories.\n\n\n0.3.4 - 2014-05-25\n------------------\n\n* Fixed django compatibility\n\n0.3.3 - 2014-04-22\n------------------\n\n* Fixed release builds\n\n\n0.3.2 - 2014-04-22\n------------------\n\n* Initial testing infrastructure\n* Add management command `babel` with `makemessages` and `compilemessages`\n labels. Mimics django's `makemessages` and `compilemessages` commands.\n* Various unicode fixes\n\n\n0.3.1 - 2013-12-11\n------------------\n\n* fix relative import in template tags\n\n\n0.3.0 - 2013-12-11\n------------------\n\n* Rename package to django_babel\n\n\n0.2.3 - 2013-12-11\n------------------\n\n* Rename package on PyPI\n* Use GitHub as source control\n\n\n.. _`master`: https://github.com/Zegocover/enmerkar\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Zegocover/enmerkar", "keywords": "", "license": "BSD", "maintainer": "Zego", "maintainer_email": "opensource@zego.com", "name": "enmerkar", "package_url": "https://pypi.org/project/enmerkar/", "platform": "", "project_url": "https://pypi.org/project/enmerkar/", "project_urls": { "Homepage": "https://github.com/Zegocover/enmerkar" }, "release_url": "https://pypi.org/project/enmerkar/0.7.1/", "requires_dist": [ "django (>=2.2)", "babel (>=1.3)" ], "requires_python": "", "summary": "Utilities for using Babel in Django", "version": "0.7.1", "yanked": false, "yanked_reason": null }, "last_serial": 6229200, "releases": { "0.7.0": [ { "comment_text": "", "digests": { "md5": "861dd7b3ae5531f3614d3f3c8cef39bc", "sha256": "a8910a5cb31ed5ef98942085b875392bb086723d8e57aecff9aacbafd113664f" }, "downloads": -1, "filename": "enmerkar-0.7.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "861dd7b3ae5531f3614d3f3c8cef39bc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 12581, "upload_time": "2019-10-21T13:45:09", "upload_time_iso_8601": "2019-10-21T13:45:09.237311Z", "url": "https://files.pythonhosted.org/packages/6c/89/2a31399e2df471b6e53b3007515cb68dd41c8bae3328860cac6475a77909/enmerkar-0.7.0-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "abb529cacacc185f1ef27cddf72241ae", "sha256": "72e7a5104370c1c65b3e5e3d61821f435ef929026600f5756a3c18c405c7e2b2" }, "downloads": -1, "filename": "enmerkar-0.7.0.tar.gz", "has_sig": false, "md5_digest": "abb529cacacc185f1ef27cddf72241ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25029, "upload_time": "2019-10-21T13:45:14", "upload_time_iso_8601": "2019-10-21T13:45:14.451408Z", "url": "https://files.pythonhosted.org/packages/85/a8/20145c0b9abe56ee84d75f763137df791e3c8cdc834361e8254c9af735d4/enmerkar-0.7.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.7.1": [ { "comment_text": "", "digests": { "md5": "cdb0098268d7df12843937a48260975b", "sha256": "ba5a79e022963580c994ce8f4fe8477d574159adbe86e5271b1a3d4127b8794d" }, "downloads": -1, "filename": "enmerkar-0.7.1-py3-none-any.whl", "has_sig": false, "md5_digest": "cdb0098268d7df12843937a48260975b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12520, "upload_time": "2019-12-02T15:16:22", "upload_time_iso_8601": "2019-12-02T15:16:22.372602Z", "url": "https://files.pythonhosted.org/packages/15/e4/89a23164cf125d336d932b1bccca185e0563ac972027e86ed87360a1f78e/enmerkar-0.7.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a4967fc49a2f6cdaf0f4cf6273508ba8", "sha256": "a4a6c859b4ed293deee40ff61d6695b3ff7bc153770a1799f2be872181282e00" }, "downloads": -1, "filename": "enmerkar-0.7.1.tar.gz", "has_sig": false, "md5_digest": "a4967fc49a2f6cdaf0f4cf6273508ba8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25059, "upload_time": "2019-12-02T15:16:23", "upload_time_iso_8601": "2019-12-02T15:16:23.744658Z", "url": "https://files.pythonhosted.org/packages/8f/6e/3930a6a285fbb350bdaf648569febeaf96ddb5813aa76c608000f73bc636/enmerkar-0.7.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.7.2.dev0": [ { "comment_text": "", "digests": { "md5": "5157e24a241563bceba58b0bc53f3d31", "sha256": "e477623359071c878bc2e5a2f542a83a3dc78ed12f4a0aa103f3d06313f3a019" }, "downloads": -1, "filename": "enmerkar-0.7.2.dev0-py3-none-any.whl", "has_sig": false, "md5_digest": "5157e24a241563bceba58b0bc53f3d31", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12613, "upload_time": "2019-12-02T15:10:38", "upload_time_iso_8601": "2019-12-02T15:10:38.637283Z", "url": "https://files.pythonhosted.org/packages/bf/d4/9c9267f10609b73508f6bda9f24e5558866ea2cb93bfa0d3e5b641583322/enmerkar-0.7.2.dev0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "0003e6b5040bdcc7b05f06f453f5949d", "sha256": "99ee8d14060d32d19da15613bd2082c8881f225b109338ec5927d86c2cfe7fc7" }, "downloads": -1, "filename": "enmerkar-0.7.2.dev0.tar.gz", "has_sig": false, "md5_digest": "0003e6b5040bdcc7b05f06f453f5949d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25113, "upload_time": "2019-12-02T15:10:40", "upload_time_iso_8601": "2019-12-02T15:10:40.281086Z", "url": "https://files.pythonhosted.org/packages/96/fd/7d97585bb18c9a4e7a9c651274dbb44734ccb251e9b1cb8efc9df199edbe/enmerkar-0.7.2.dev0.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cdb0098268d7df12843937a48260975b", "sha256": "ba5a79e022963580c994ce8f4fe8477d574159adbe86e5271b1a3d4127b8794d" }, "downloads": -1, "filename": "enmerkar-0.7.1-py3-none-any.whl", "has_sig": false, "md5_digest": "cdb0098268d7df12843937a48260975b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12520, "upload_time": "2019-12-02T15:16:22", "upload_time_iso_8601": "2019-12-02T15:16:22.372602Z", "url": "https://files.pythonhosted.org/packages/15/e4/89a23164cf125d336d932b1bccca185e0563ac972027e86ed87360a1f78e/enmerkar-0.7.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a4967fc49a2f6cdaf0f4cf6273508ba8", "sha256": "a4a6c859b4ed293deee40ff61d6695b3ff7bc153770a1799f2be872181282e00" }, "downloads": -1, "filename": "enmerkar-0.7.1.tar.gz", "has_sig": false, "md5_digest": "a4967fc49a2f6cdaf0f4cf6273508ba8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25059, "upload_time": "2019-12-02T15:16:23", "upload_time_iso_8601": "2019-12-02T15:16:23.744658Z", "url": "https://files.pythonhosted.org/packages/8f/6e/3930a6a285fbb350bdaf648569febeaf96ddb5813aa76c608000f73bc636/enmerkar-0.7.1.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }