A Django app which provides support for model translation.
Project description
Translations provides an easy and efficient way of translating model contents.
Requirements
Python (>=3.5) - Python 2.7 is NOT supported.
Django (1.11, 2.0) - Django 2.1 is NOT supported (yet).
Installation
Install Translations using PIP (use --pre, still in development):
$ pip install --pre django-translations
Add 'translations' to INSTALLED_APPS in the settings of your Django project:
INSTALLED_APPS = [ ... 'translations', ... ]
Run migrate:
$ python manage.py migrate
Usage
Model
Inherit Translatable in any model you want translated.
No migrations needed afterwards! That’s it!
from translations.models import Translatable class Question(Translatable): ... class Choice(Translatable): ...
Query
You can use the extended ORM querysets:
>>> q = Question.objects.create_translated( ... question_text="What's up?", ... category='usuals', ... lang='en' ... ) <Question: What's up?> >>> q.question_text = 'Quoi de neuf?' >>> q.category = 'habituels' >>> q.update_translations( ... lang='fr' ... ) >>> q.get_translated(lang='en') <Question: What's up?> >>> q.get_translated(lang='fr') <Question: Quoi de neuf?>
Admin
You can also use the admin extensions:
from django.contrib import admin from translations.admin import TranslatableAdmin, TranslationInline from .models import Question class QuestionAdmin(TranslatableAdmin): inlines = [TranslationInline,] admin.site.register(Question, QuestionAdmin)
Documentation
For more interesting capabilities browse through the documentation.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-translations-1.0.0.dev1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | bca624bddb1015fa33bf895b188ae4e97c127531bca2ca41fc84ee5dab6183e1 |
|
MD5 | 6c2db1330584de605b93d195fb692679 |
|
BLAKE2b-256 | ccbb7f2bec4f8a0fa0a0e6a6f589238205fad0f676314c78782640a4826d010f |
Hashes for django_translations-1.0.0.dev1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70f57df672f4ce9a268e7de37933d23c07076f04dbb79b2b46f17654e08e3854 |
|
MD5 | 9e113df6c56012474980b165c2525729 |
|
BLAKE2b-256 | a292ab1d7f2daadcf807817380c91166b686222478fc48a4e13746610f1eb788 |