Skip to main content

A Django app which provides support for model translation.

Project description

https://travis-ci.com/perplexionist/django-translations.svg?branch=master

Translations app provides an easy and efficient way of translating model contents.

Requirements

  • Python (>=3.5)

  • Django (1.11, >=2.0)

Installation

  1. Install Translations using PIP (use --pre, still in development):

    $ pip install --pre django-translations
  2. Add 'translations' to INSTALLED_APPS in the settings of your Django project:

    INSTALLED_APPS = [
        ...
        'translations',
        ...
    ]
  3. 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(
...     question_text="What's up?",
...     category='usuals',
... )
<Question: What's up?>
>>> q.question_text = 'Quoi de neuf?'
>>> q.category = 'habituels'
>>> q.update_translations(lang='fr')
>>> q.apply_translations(lang='en')
<Question: What's up?>
>>> q.apply_translations(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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-translations-1.0.0.dev3.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

django_translations-1.0.0.dev3-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file django-translations-1.0.0.dev3.tar.gz.

File metadata

  • Download URL: django-translations-1.0.0.dev3.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for django-translations-1.0.0.dev3.tar.gz
Algorithm Hash digest
SHA256 cbcad6fdee69e1b566d2c4b5de6560c6a1dbdf367ca193fc48505905b6642e22
MD5 a9906d929e6a80d5abbeed15ada59ff3
BLAKE2b-256 5e8170cbc0bda368e7234a2e8a90a716053764b356cfe323ed8617e957f63fd6

See more details on using hashes here.

Provenance

File details

Details for the file django_translations-1.0.0.dev3-py3-none-any.whl.

File metadata

  • Download URL: django_translations-1.0.0.dev3-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3

File hashes

Hashes for django_translations-1.0.0.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 7667a28e537e17f7c1dd60d800a7ec446b64cf665e3e50ef42a8ad735488705f
MD5 c3823cdde9257013c5e860decf0b9733
BLAKE2b-256 5278e3c641a7c8fd413284859bfec7334c0fe7cf9953868ad6b21d61427721d9

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page