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.4.0.tar.gz (4.3 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for django-i18n-utils-1.4.0.tar.gz
Algorithm Hash digest
SHA256 35e734e48f51bbaf2dcbc9ee12dc8c7a60f70ee2f64e26b34fd8a6f1a19962a3
MD5 3b74fd2e0fd64fd90f1a51865175389c
BLAKE2b-256 11c23f9e0a6e13fdca0037c2e2c21b2f088c0b150d461cc6094b4005e8b8e418

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