{ "info": { "author": "Thread Engineering", "author_email": "tech@thread.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 6 - Mature", "Framework :: Django", "Framework :: Django :: 2.0", "Framework :: Django :: 2.1", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Internationalization" ], "description": "# Django Translations\n\nNOTE: This package is a fork of\nhttps://github.com/bbmokhtari/django-translations. It contains features and\nfixes not yet available in the original package, but will not by maintained for\npublic use. Please depend on the original package.\n\n[![build](https://travis-ci.com/bbmokhtari/django-translations.svg?branch=master)](https://travis-ci.com/bbmokhtari/django-translations)\n[![python](https://img.shields.io/badge/python-3.5%7C3.6-0073b7.svg)](https://pypi.org/project/django-translations/)\n[![pypi](https://img.shields.io/badge/pypi-1.0.0-f9d35f.svg)](https://pypi.org/project/django-translations/)\n[![django](https://img.shields.io/badge/django-2.0%7C2.1-0C4B33.svg)](https://pypi.org/project/django-translations/)\n[![flake8](https://img.shields.io/badge/flake8-linted-green.svg)](https://travis-ci.com/bbmokhtari/django-translations)\n\nDjango model translation for perfectionists with deadlines.\n\n## Goal\n\nThere are two types of content, each of which has its own challenges for translation:\n\n- Static content: This is the content which is defined in the code.\n _e.g. \"Please enter a valid email address.\"_\n\n Django already provides a\n [solution](https://docs.djangoproject.com/en/2.1/topics/i18n/translation/)\n for translating static content.\n\n- Dynamic content: This is the content which is stored in the database.\n _(We can't know it beforehand!)_\n\n Django Translations provides a solution\n for translating dynamic content.\n\n## Requirements\n\n- Python (\\>=3.5)\n- Django (\\>=2.0)\n\n## Installation\n\n1. Install Django Translations using pip:\n\n ``` bash\n $ pip install django-translations\n ```\n\n2. Add `translations` to the `INSTALLED_APPS` in the settings of your\n project:\n\n ``` python\n INSTALLED_APPS += [\n 'translations',\n ]\n ```\n\n3. Run `migrate`:\n\n ``` bash\n $ python manage.py migrate\n ```\n\n4. Configure Django internationalization and localization settings:\n\n ``` python\n USE_I18N = True # use internationalization\n USE_L10N = True # use localization\n\n MIDDLEWARE += [ # locale middleware\n 'django.middleware.locale.LocaleMiddleware',\n ]\n\n LANGUAGE_CODE = 'en-us' # default (fallback) language\n LANGUAGES = ( # supported languages\n ('en', 'English'),\n ('en-gb', 'English (Great Britain)'),\n ('de', 'German'),\n ('tr', 'Turkish'),\n )\n ```\n\n Please note that these settings are for Django itself.\n\n## Basic Usage\n\n### Model\n\nInherit `Translatable` in any model you want translated:\n\n``` python\nfrom translations.models import Translatable\n\nclass Continent(Translatable):\n code = models.Charfield(...)\n name = models.Charfield(...)\n denonym = models.Charfield(...)\n\n class TranslatableMeta:\n fields = ['name', 'denonym']\n```\n\nNo migrations needed afterwards.\n\n### Admin\n\nUse the admin extensions:\n\n``` python\nfrom translations.admin import TranslatableAdmin, TranslationInline\n\nclass ContinentAdmin(TranslatableAdmin):\n inlines = [TranslationInline,]\n```\n\nThis provides specialized translation inlines for the model.\n\n![image](https://raw.githubusercontent.com/bbmokhtari/django-translations/master/docs/_static/admin.png)\n\n## QuerySet\n\nUse the queryset extensions:\n\n``` python\n>>> from sample.models import Continent\n>>> continents = Continent.objects.all(\n... ).distinct( # familiar distinct\n... ).probe(['en', 'de'] # probe (filter, exclude, etc.) in English and German\n... ).filter( # familiar filtering\n... countries__cities__name__startswith='K\u00f6ln'\n... ).translate('de' # translate the results in German\n... ).translate_related( # translate these relations as well\n... 'countries', 'countries__cities',\n... )\n>>> print(continents)\n,\n]>\n>>> print(continents[0].countries.all())\n,\n]>\n>>> print(continents[0].countries.all()[0].cities.all())\n,\n]>\n```\n\nThis provides a powerful yet familiar interface to work with the querysets.\n\n## Context\n\nUse the translation context:\n\n``` python\n>>> from translations.context import Context\n>>> from sample.models import Continent\n>>> continents = Continent.objects.all()\n>>> relations = ('countries', 'countries__cities',)\n>>> with Context(continents, *relations) as context:\n... context.read('de') # read the translations onto the context\n... print(':') # use the objects like before\n... print(continents)\n... print(continents[0].countries.all())\n... print(continents[0].countries.all()[0].cities.all())\n... \n... continents[0].countries.all()[0].name = 'Change the name'\n... context.update('de') # update the translations from the context\n... \n... context.delete('de') # delete the translations of the context\n... \n... context.reset() # reset the translations of the context\n... print(':') # use the objects like before\n... print(continents)\n... print(continents[0].countries.all())\n... print(continents[0].countries.all()[0].cities.all())\n:\n,\n ,\n]>\n,\n]>\n,\n]>\n:\n,\n ,\n]>\n,\n]>\n,\n]>\n```\n\nThis can CRUD the translations of any objects (instance, queryset, list) and their relations.\n\n## Documentation\n\nFor more interesting capabilities browse through the\n[documentation](http://bbmokhtari.github.io/django-translations).\n\n## By The Way\n\nIf you liked this library please consider giving it a star! \u2b50\ufe0f\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/thread/django-translations", "keywords": "django model translation internationalization localization", "license": "", "maintainer": "", "maintainer_email": "", "name": "django-translations-thread", "package_url": "https://pypi.org/project/django-translations-thread/", "platform": "", "project_url": "https://pypi.org/project/django-translations-thread/", "project_urls": { "Documentation": "https://thread.github.io/django-translations", "Homepage": "https://github.com/thread/django-translations", "Source": "https://github.com/thread/django-translations", "Tracker": "https://github.com/thread/django-translations/issues" }, "release_url": "https://pypi.org/project/django-translations-thread/0.0.3/", "requires_dist": null, "requires_python": ">=3.5, <4", "summary": "Django model translation for perfectionists with deadlines.", "version": "0.0.3" }, "last_serial": 5455460, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "52c3080e31ab9d7b3fe01a5339a66b9d", "sha256": "ee53f28d6d5c50fb3ae9bb3965ded649bc66a435fb1b089b54904ddd63edb1a8" }, "downloads": -1, "filename": "django_translations_thread-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "52c3080e31ab9d7b3fe01a5339a66b9d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 23546, "upload_time": "2019-06-24T06:14:59", "url": "https://files.pythonhosted.org/packages/b2/2b/50c0a17cdf7ee5a4f800dab4f728d27a490632a06ce58267adebf340503b/django_translations_thread-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "2d30841967c182c6e66c7d7de8e0a4aa", "sha256": "12a6df7cc5cc5ee9f9539f775b9d4ff6f3a433d74d2583670c055f2334566391" }, "downloads": -1, "filename": "django-translations-thread-0.0.1.tar.gz", "has_sig": false, "md5_digest": "2d30841967c182c6e66c7d7de8e0a4aa", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 30573, "upload_time": "2019-06-24T06:15:02", "url": "https://files.pythonhosted.org/packages/54/46/aca548740cd52dbd5babd3955148243d3dabfaa60e66ce0837f17c088324/django-translations-thread-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "7e5dd5104a114d3641b331da35d6e9f4", "sha256": "1c88284dc311e15b7c95596401ca0169f85969a33edb8047e76dd940b3f41f00" }, "downloads": -1, "filename": "django_translations_thread-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "7e5dd5104a114d3641b331da35d6e9f4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 23653, "upload_time": "2019-06-24T06:23:14", "url": "https://files.pythonhosted.org/packages/78/e5/1a87c2f5dcc6f1f4fdbc6f289ad1a117d4b11ee94465cf3e6bb5ca3f342b/django_translations_thread-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "70f39ce2a142f4b122066297c42dc76d", "sha256": "24f2a2a63cea390590f8e673f38427b3d77c7f96810b735d9fc578ad674c2b1d" }, "downloads": -1, "filename": "django-translations-thread-0.0.2.tar.gz", "has_sig": false, "md5_digest": "70f39ce2a142f4b122066297c42dc76d", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 30690, "upload_time": "2019-06-24T06:23:16", "url": "https://files.pythonhosted.org/packages/1e/80/eab011b418928cfb3be107885d6bc3f5ed183c6a264336289a336b242db0/django-translations-thread-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "d9f95ea555ccde531f1e77b36e40ddb7", "sha256": "a6200cb2dcaebc1348b11e19f08d1724f98e6a61846ba82f282af97213cfa27b" }, "downloads": -1, "filename": "django_translations_thread-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d9f95ea555ccde531f1e77b36e40ddb7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 23653, "upload_time": "2019-06-27T07:14:12", "url": "https://files.pythonhosted.org/packages/f6/5a/1ea43dc421d7df2a6928ea444bee5fb7d72950c7d27796fe714d43ab470c/django_translations_thread-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc1a78d3bae67f9ec02d86bfdb3f284e", "sha256": "c0dede07a5de844d4eca5ef6c47313ea13cc253972ffe5c5915a11508512a1fc" }, "downloads": -1, "filename": "django-translations-thread-0.0.3.tar.gz", "has_sig": false, "md5_digest": "fc1a78d3bae67f9ec02d86bfdb3f284e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 31192, "upload_time": "2019-06-27T07:14:15", "url": "https://files.pythonhosted.org/packages/46/45/031333df0c5724212c87507dfc969b2a4e0f9adfe303b56b7f6dd39a27b8/django-translations-thread-0.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d9f95ea555ccde531f1e77b36e40ddb7", "sha256": "a6200cb2dcaebc1348b11e19f08d1724f98e6a61846ba82f282af97213cfa27b" }, "downloads": -1, "filename": "django_translations_thread-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d9f95ea555ccde531f1e77b36e40ddb7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=3.5, <4", "size": 23653, "upload_time": "2019-06-27T07:14:12", "url": "https://files.pythonhosted.org/packages/f6/5a/1ea43dc421d7df2a6928ea444bee5fb7d72950c7d27796fe714d43ab470c/django_translations_thread-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fc1a78d3bae67f9ec02d86bfdb3f284e", "sha256": "c0dede07a5de844d4eca5ef6c47313ea13cc253972ffe5c5915a11508512a1fc" }, "downloads": -1, "filename": "django-translations-thread-0.0.3.tar.gz", "has_sig": false, "md5_digest": "fc1a78d3bae67f9ec02d86bfdb3f284e", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5, <4", "size": 31192, "upload_time": "2019-06-27T07:14:15", "url": "https://files.pythonhosted.org/packages/46/45/031333df0c5724212c87507dfc969b2a4e0f9adfe303b56b7f6dd39a27b8/django-translations-thread-0.0.3.tar.gz" } ] }