{ "info": { "author": "intelligenia S.L.", "author_email": "diego@intelligenia.es", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Django", "License :: OSI Approved :: MIT License" ], "description": "modeltranslation\n================\n\nVersi\u00f3n en espa\u00f1ol en `README.es.md `__\n\nIntroduction\n------------\n\nThis application allows you use\n`Django `__ model translations easily.\nEverything is based on FieldTranslation, a class that stores the\ntranslation of each field of your application models.\n\nAll the process is transparent and the entries are created when save is\ncalled.\n\nYou will not have to modify FieldTranslation, but you can read the code.\n\nAll code in in the github repository:\nhttps://github.com/intelligenia/modeltranslation\n\nInstructions\n------------\n\nInstallation\n~~~~~~~~~~~~\n\nThis application depends on\n`django-cuser `__ and\n`TinyMCE `__, so you will\nneed to install it and put it in the list of INSTALLED\\_APPS before\nmodeltranslation.\n\nYou are encouraged to use pip to install django-cuser.\n\nThe easiest way to install modeltranslation is by installing it from\n`pipy `__:\n\n.. code:: sh\n\n pip install modeltranslation\n\nOnce you've done this, you can install modeltranslation in settings.py:\n\nINSTALLED\\_APPS = ( \"tinymce\", \"cuser\", \"modeltranslation\" )\n\nAdd IS\\_MONOLINGUAL to settings.py\n----------------------------------\n\nYou'll have to include a new setting in settings.py\nIS\\_MONOLINGUAL=False. IS\\_MONOLINGUAL acts as a switch for\nmodeltranslation:\n\n.. code:: python\n\n # modeltranslation only works when IS_MONOLINGUAL is False\n IS_MONOLINGUAL=False\n\nAdd TRANSLATABLE\\_MODEL\\_MODULES to settings.py\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nAdd file setting TRANSLATABLE\\_MODEL\\_MODULES to settings.py.\nTRANSLATABLE\\_MODEL\\_MODULES contains a list of module paths that will\nbe translated. For example:\n\n.. code:: python\n\n TRANSLATABLE_MODEL_MODULES = [\"app1.models\", \"app2.models\", \"fees.models\", \"menus.models\", ...]\n\nImport addtranslations\n----------------------\n\nImport **addtranslations** if each of your models.py files:\n\n.. code:: python\n\n from modeltranslation.translation import addtranslations\n\nAfter that, you'll have to call **addtranslations** at the end of this\nfile:\n\n.. code:: python\n\n addtranslations(__name__)\n\nThis call adds an observer that saves translations when **save** model\nmethod is executed.\n\nAdd translatable\\_fields to your models\n---------------------------------------\n\nModify your models including a meta field \"translatable\\_fields\". This\nfield is a list with the fields you want to translate.\n\nFor example:\n\n.. code:: python\n\n from django.db import models\n\n class Event(models.Model):\n \n name = models.CharField(blank=False, max_length=150, verbose_name=u\"Name\", help_text=u\"Name of the event.\")\n description = models.TextField(blank=False, verbose_name=u\"Description\", help_text=u\"Long description of the event.\")\n short_description = models.CharField(blank=False, max_length=150, verbose_name=u\"Short description\", help_text=u\"Short description of the event.\")\n\n #...\n\n ## Event Meta\n class Meta:\n verbose_name = \"event\"\n verbose_name_plural = \"events\"\n translatable_fields = (\"name\", \"description\", \"short_description\")\n\nAnd that's all!\n~~~~~~~~~~~~~~~\n\nNow you have everything configurated and can use modeltranslation\ntranslations.\n\nHow to use translations in ModelForms\n-------------------------------------\n\nMake your ModelForm object inherits of TranslatableModelForm. This will\ninclude automatically the extra fields for each language you have in\nyour website.\n\n.. code:: python\n\n from modeltranslation.forms import TranslatableModelForm\n\n class EventForm(TranslatableModelForm):\n pass\n\nIf you need to modify any of the fields in **init** method (for example\nby changing the widget of one field), you'll have to call\n\\_add\\_translation\\_form\\_fields after your changes.\n\nFor example:\n\n.. code:: python\n\n # EventForm __init__ \n def __init__(self, event, *args, **kwargs):\n super(EventForm, self).__init__(*args, **kwargs)\n \n # Adds TinyMCE editor but we also want this editor in other\n # languages' description fields\n self.fields[\"description\"].widget = TinyMCE()\n \n # Manually adition of translation fields\n self._add_translation_form_fields()\n\nDynamic translations in Django templates\n----------------------------------------\n\n1. Include modeltranslation filters in each template you wan to use this\n special filters.\n\n.. code:: django\n\n {% load modeltranslation_tags %}\n\n2. Use filter \"\\_\" with the object and one of its fields. This filter\n will return the translation of that field in the current language.\n\nFor example:\n\n.. code:: django\n\n {{ event|_:\"name\" }} {# Translates event name #}\n {{ event.area|_:\"name\" }} {# Translates area name #}\n\nDynamic translations in code\n----------------------------\n\nThis application injects a new method to each translatable model:\n**get\\_trans\\_attr**. This method returns the translation of the\nattribute in the current language (if it exists), otherwise returns the\ndefault value for this attribute:\n\nFor example:\n\n.. code:: python\n\n\n # Original event name\n original_event_name event.name\n\n # Translated event name\n translated_event_name event.get_trans_attr(\"name\")\n\nContact and suggestions\n-----------------------\n\n- Create a new issue in this repository.\n- Email me at diegoREMOVE\\_THIS@intelligeniaREMOVE\\_THIS.com", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/intelligenia/modeltranslation", "keywords": "modeltranslation translations", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "modeltranslation", "package_url": "https://pypi.org/project/modeltranslation/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/modeltranslation/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/intelligenia/modeltranslation" }, "release_url": "https://pypi.org/project/modeltranslation/0.25/", "requires_dist": null, "requires_python": null, "summary": "Modeltranslation is an utility to translate Django model fields.", "version": "0.25" }, "last_serial": 4306160, "releases": { "0.2": [ { "comment_text": "", "digests": { "md5": "4917d762e6a922f5003e94d19fdc4d9d", "sha256": "9f7d8616f6a8ca89bd894877db7d560b4dae2b017f65de62f04ba5dff10f217b" }, "downloads": -1, "filename": "modeltranslation-0.2.tar.gz", "has_sig": false, "md5_digest": "4917d762e6a922f5003e94d19fdc4d9d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 171129, "upload_time": "2016-12-23T13:36:22", "url": "https://files.pythonhosted.org/packages/eb/7f/a451b1d8638432f8054fe3805a80e8f43df39d29aeb6726b0951f7fe22a0/modeltranslation-0.2.tar.gz" } ], "0.21": [ { "comment_text": "", "digests": { "md5": "3bb54dbb8e68f46370cf065ab46b1da0", "sha256": "3bc36d618e361e3621f1b1a634865a13db79a0774af6c5471426e75e43c3aa43" }, "downloads": -1, "filename": "modeltranslation-0.21.tar.gz", "has_sig": false, "md5_digest": "3bb54dbb8e68f46370cf065ab46b1da0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 321090, "upload_time": "2016-12-23T13:44:26", "url": "https://files.pythonhosted.org/packages/56/c1/44e94cb6621cf3e76ec10ee672e4062a13cfe734a03f6364e30c5123bb85/modeltranslation-0.21.tar.gz" } ], "0.22": [ { "comment_text": "", "digests": { "md5": "4fc3495690e732679fb98a21cfdb8b5e", "sha256": "e54b5ae557c96edbafb6769df1f09df0a9f10da7fe6fbdc215914edf27c42d62" }, "downloads": -1, "filename": "modeltranslation-0.22.tar.gz", "has_sig": false, "md5_digest": "4fc3495690e732679fb98a21cfdb8b5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 641880, "upload_time": "2016-12-23T13:46:03", "url": "https://files.pythonhosted.org/packages/bf/e0/037c1ef141cd9835d1990f63fcdc4495f52edac0dad56cbaa5ebec59e7a1/modeltranslation-0.22.tar.gz" } ], "0.23": [ { "comment_text": "", "digests": { "md5": "84796d6a7b07308913eb188047e40947", "sha256": "b1d019364b448dc15eb14edfbcc41e32467de7ebb385c8093c97508e29807cea" }, "downloads": -1, "filename": "modeltranslation-0.23.tar.gz", "has_sig": false, "md5_digest": "84796d6a7b07308913eb188047e40947", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1284726, "upload_time": "2016-12-23T13:48:43", "url": "https://files.pythonhosted.org/packages/32/b9/bdb97baddbb2d716e664aa2e691c855bedac28bb842a4e2c77acfdc50d53/modeltranslation-0.23.tar.gz" } ], "0.24": [ { "comment_text": "", "digests": { "md5": "3ca4c0bf9e9bd54e59f87faf48d66bcb", "sha256": "714f5dffe922621b450a51a18e5b7acac88b773ff33b4fe78f6e203f18412936" }, "downloads": -1, "filename": "modeltranslation-0.24.tar.gz", "has_sig": false, "md5_digest": "3ca4c0bf9e9bd54e59f87faf48d66bcb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2570281, "upload_time": "2016-12-23T13:54:42", "url": "https://files.pythonhosted.org/packages/a2/68/1e77126780e913612f33ada07d5c47f5966205b4811ba7125adea1117ded/modeltranslation-0.24.tar.gz" } ], "0.25": [ { "comment_text": "", "digests": { "md5": "b7aa36073eeee19cd7631e5b7f583759", "sha256": "6b13273ea51e36cccecf32ea87299f7ef19a741222b6d0cf3753870fa5f754bc" }, "downloads": -1, "filename": "modeltranslation-0.25.tar.gz", "has_sig": false, "md5_digest": "b7aa36073eeee19cd7631e5b7f583759", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5140976, "upload_time": "2017-03-15T18:54:48", "url": "https://files.pythonhosted.org/packages/30/f4/b00c8efa1e229d15d720ccf078f2aa035fd3bd5cbbf5dcd99ec71fef1a90/modeltranslation-0.25.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b7aa36073eeee19cd7631e5b7f583759", "sha256": "6b13273ea51e36cccecf32ea87299f7ef19a741222b6d0cf3753870fa5f754bc" }, "downloads": -1, "filename": "modeltranslation-0.25.tar.gz", "has_sig": false, "md5_digest": "b7aa36073eeee19cd7631e5b7f583759", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5140976, "upload_time": "2017-03-15T18:54:48", "url": "https://files.pythonhosted.org/packages/30/f4/b00c8efa1e229d15d720ccf078f2aa035fd3bd5cbbf5dcd99ec71fef1a90/modeltranslation-0.25.tar.gz" } ] }