Skip to main content

django-t10e

pypi-badge build-status

django-t10e is an approach that allows you to translate the contents of your models. django-t10e stands for django-translatable.

The concept behind django-t10e is that we have one model instance per language. This means one object that is translated into two different languages will be represented by two rows in the model’s database table. Every translatable model has a language field and a translation_set field.

language obviously defines the language of each translation and translation_set groups the translations of one entity together. All instances with the same translation_set are considered to be different translations of the same entity. An entity might be a news article that is translated into multiple languages..

The translation_set field is a models.ForeignKey('self') field, so it always points to instances of the same model. The first saved instance of one translation will set this foreign key to its own primary key. The instance to which all translations of one entity point to (the first translation) is called the base translation.

An example. Let’s assume the following page instances:

  • Article(id=13, title='I18N is hard', language='en', translation_set=13)

  • Article(id=14, title='Internationalisierung ist schwer', language='de', translation_set=13)

  • Article(id=15, title='La internacionalización es dura', language='es', translation_set=13)

The article with id=13 is considered the base translation. id=14 is the german translation of id=13. id=15 is the spanish translation of id=13. All three make up one translation set for the “I18N is hard” article.

There might also be fields that don’t need translation, like date fields etc. These are synced in the translation set. For example: an article model might have a pub_date field. So all translations in one translation set have the same pub_date value assigned. When one translation is changed you need to call the update_translations() method. That will update all other instances in the translation set accordingly.

Development

Install the dependencies (including the test dependencies) with:

pip install -r requirements.txt

Then you can run all tests with:

tox

Changelog

0.1.0

  • Initital release.

Metadata

Release files for django-t10e 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-t10e 0.1.0
File Size Uploaded Provenance
django-t10e-0.1.0.tar.gz 11.6 kB Without provenance Details

Release files / django-t10e-0.1.0.tar.gz

Download URL django-t10e-0.1.0.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
898c37e6a9a46a0642e23f800ce217c873b9ee38b6c2357b8a1c00331f0f7878
BLAKE2b-256 checksum
How to use checksums
04e71e00f16b3d8af904bd9dacffba3e6f308a354ed43f1b737d9c04d3fe5f0d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-t10e 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page