{"id":18940997,"url":"https://github.com/dreipol/django-translator","last_synced_at":"2025-04-15T19:31:53.035Z","repository":{"id":15656501,"uuid":"18393853","full_name":"dreipol/django-translator","owner":"dreipol","description":"Translator is an app for collecting translations for specified keys in django admin.","archived":false,"fork":false,"pushed_at":"2024-09-04T15:10:00.000Z","size":42,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-29T01:51:46.538Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/dreipol/django-translator","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dreipol.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-04-03T06:48:09.000Z","updated_at":"2024-09-04T15:09:55.000Z","dependencies_parsed_at":"2024-06-21T14:24:08.372Z","dependency_job_id":"79e4b7ef-7a63-40ab-a870-b8bf9255dd88","html_url":"https://github.com/dreipol/django-translator","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreipol%2Fdjango-translator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreipol%2Fdjango-translator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreipol%2Fdjango-translator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dreipol%2Fdjango-translator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dreipol","download_url":"https://codeload.github.com/dreipol/django-translator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650482,"owners_count":21139676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T12:25:12.509Z","updated_at":"2025-04-15T19:31:52.753Z","avatar_url":"https://github.com/dreipol.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"===========\nTranslator\n===========\n\nTranslator is an app for collecting translations for specified keys in django admin.\n\nQuick start\n-----------\n#. Install django-translator: ``pip install django-translator``\n\n#. Add \"translator, taggit, modeltranslation\" to your INSTALLED_APPS setting. Please note that ``modeltranslation`` needs to be before ``django.contrib.admin``::\n\n\tINSTALLED_APPS = (\n\t'modeltranslation',\n\t'django.contrib.admin',\n\t...\n\t'taggit',\n\t'translator',\n\t)\n\n#. You have to set the migrations folder for the translator, because we have to add migrations for the set languages.  Add the following to your settings file::\n\n\tMIGRATION_MODULES = {\n\t    'translator': 'my_project.translator_migrations',\n\t}\n\n#. Create a ``translator_migrations`` python package in your project folder (where your settings.py usually is).\n\n#. Run ``python manage.py makemigrations translator`` to create the translator models based on the languages you specified in your settings file.\n\n#. Run ``python manage.py migrate`` to migrate the translator models to your database.\n\n#. If you intend to use it in the templates, add 'translator.context_processors.translator' to TEMPLATE_CONTEXT_PROCESSORS ::\n\n\t TEMPLATE_CONTEXT_PROCESSORS = (\n\t \t...\n\t    'translator.context_processors.translator',\n\t )\n\n#. Create translation keys in your templates and models.\n\n\tExamples:\n\n\tTemplate::\n\n\t\t{{ translator.a_key }}\n\n\tmodels.py::\n\n\t\tfrom translator.util import translator_lazy as _\n\t\t...\n\n\t\tclass Product(models.Model):\n\t\t    name = models.TextField(verbose_name=_('a_key'))\n\n#. Visit the templates. The keys get collected lazy.\n\n#. Translate the keys in the admin.\n\n\n#. You can disable the translator by setting DJANGO_TRANSLATOR_ENABLED to False.\n\n#. Use a double underscore in your translation keys to make use of the filter in the admin (e.g. \"header__title\" creates a filter called \"header\"). If you need another separator, set it as DJANGO_TRANSLATOR_CATEGORY_SEPARATOR in your setting file.\n\n\nCustom Models\n-------------\n\nIf you find yourself in a situation where you need to use the features of django-translator in a second isolated model, feel free to add one:\n\n#. Create a new model in your app::\n\n    from translator.models import TranslationBase\n\n    class MyCustomTranslation(TranslationBase):\n        pass\n\n\n#. Create a new file `translation.py` and register your model for modeltranslation support::\n\n    from modeltranslation.translator import translator, TranslationOptions\n    from myapp.models import MyCustomTranslation\n\n    class MyCustomTranslationOptions(TranslationOptions):\n        fields = ('description',)\n\n    translator.register(MyCustomTranslation, MyCustomTranslationOptions)\n\n\n#. Add a django admin in `admin.py`::\n\n    from django.contrib import admin\n    from translator.admin import TranslationAdministration\n    from myapp.models import MyCustomTranslation\n\n    @admin.register(MyCustomTranslation)\n    class CustomTranslationAdmin(TranslationAdministration):\n        pass\n\n\n#. Add your model to your settings file::\n\n    DJANGO_TRANSLATOR_MODELS = {\n        'custom_translation': 'myapp.models.MyCustomTranslation',\n    }\n\n\n#. Create translation keys in your templates and models.\n\n\tExamples:\n\n\tTemplate::\n\n\t\t{{ custom_translation.a_key }}\n\n\tmodels.py::\n\n\t\tfrom myapp.util import custom_translation_lazy\n\t\t...\n\n\t\tclass Product(models.Model):\n\t\t    name = models.TextField(verbose_name=translator_lazy('a_key', 'custom_translation'))\n\nSettings\n-------------\nCustomize the translator in your settings.py file with these settings::\n\n\tDJANGO_TRANSLATOR_CACHE_TIMEOUT = timeout in seconds, if not set defaults to DEFAULT_TIMEOUT, which is either the CACHES['TIMEOUT'] setting or 300 (5 minutes)\n\n\nProject Home\n------------\nhttps://github.com/dreipol/django-translator\n\nPyPi\n------------\nhttps://pypi.python.org/pypi/django-translator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreipol%2Fdjango-translator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdreipol%2Fdjango-translator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdreipol%2Fdjango-translator/lists"}