Skip to main content

Utilities for localized Django projects

Project description

https://travis-ci.org/acdha/django-i18n-utils.svg?branch=master

Data Processing

clean_unicode

utils.clean_unicode accepts an input string and returns normalized Unicode

UnicodeNormalizerMixin

Model mixin class which ensures that every text field has been processed with clean_unicode during model validation’s clean_fields step

Testing

TranslationSafeTestClient

Django TestClient subclass which resets the active translation after each request to avoid leaking translation state across tests, causing hard-to-debug side-effects like loading fixtures in the wrong language using django-modeltranslation.

Usage:

from django_i18n_utils.testclients import TranslationSafeTestClient

class MyTestCase(TestCase):
    client_class = TranslationSafeTestClient

    def test_foo(self):
        # default language active
        self.client.get('/pt/myview') # Portuguese active when the view executes
        # default language active again

LocalizedTestCase

Django TestCase subclass which makes it easy to create per-language tests without duplication or for-loops:

class MyLocalizedTests(LocalizedTestCase):
    def test_homepage(self):
        …

will execute and display as if you had really created this:

class MyLocalizedTests(LocalizedTestCase):
    def test_homepage_en(self):
        … # test English
    def test_homepage_es(self):
        … # test Spanish

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-i18n-utils-1.3.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distributions

django_i18n_utils-1.3.0-py27-none-any.whl (6.7 kB view details)

Uploaded Python 2.7

django_i18n_utils-1.3.0-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file django-i18n-utils-1.3.0.tar.gz.

File metadata

File hashes

Hashes for django-i18n-utils-1.3.0.tar.gz
Algorithm Hash digest
SHA256 fd16679395d6f46e5bab672b79cd921e50d187b57f83f3a82ad1d18c608e4798
MD5 5cb64e181084b2409b58fd5ef0f18ff2
BLAKE2b-256 e0ead4353496d056ead778a97d55bf5dbc509eaf9bb9c5347b0267e4a7684794

See more details on using hashes here.

File details

Details for the file django_i18n_utils-1.3.0-py27-none-any.whl.

File metadata

File hashes

Hashes for django_i18n_utils-1.3.0-py27-none-any.whl
Algorithm Hash digest
SHA256 f0a1850e8f7cfc6917a4f902a86a7140b2d0a05f3fc0e75d15e3abcf1b9b1263
MD5 6d1991eb5d7dd43c351e85e6fe291e45
BLAKE2b-256 02336f1154802175f7544e0c096e7d78216678b1fd3bd46f3dd7225749243e17

See more details on using hashes here.

File details

Details for the file django_i18n_utils-1.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_i18n_utils-1.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 311acb4e1e280e970a2ea58dde7b9f8cdf6c40769aefc64bd7ab7230e2550166
MD5 a083c61dba9a3d964b519b6651012a84
BLAKE2b-256 86f8fed6db28e674cd05c5e7d67e4b9be32cd10bfd544a0e8ead39fd29248f48

See more details on using hashes here.

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