Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/acdha/django-i18n-utils
i18n utilities for Django projects
https://github.com/acdha/django-i18n-utils
Last synced: 3 months ago
JSON representation
i18n utilities for Django projects
- Host: GitHub
- URL: https://github.com/acdha/django-i18n-utils
- Owner: acdha
- Created: 2012-08-21T21:40:13.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2019-01-11T19:42:03.000Z (about 6 years ago)
- Last Synced: 2024-10-31T04:50:47.977Z (3 months ago)
- Language: Python
- Homepage: https://pypi.python.org/pypi/django-i18n-utils
- Size: 21.5 KB
- Stars: 6
- Watchers: 4
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
=================================
Django Internationalization Utils
=================================.. image:: https://travis-ci.org/acdha/django-i18n-utils.svg?branch=master
:target: https://travis-ci.org/acdha/django-i18n-utilsData Processing
~~~~~~~~~~~~~~~clean_unicode
-------------`utils.clean_unicode` accepts an input string and returns
normalized UnicodeUnicodeNormalizerMixin
----------------------Model mixin class which ensures that every text field has been processed with
`clean_unicode` during model validation's `clean_fields` stepTesting
~~~~~~~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 = TranslationSafeTestClientdef test_foo(self):
# default language active
self.client.get('/pt/myview') # Portuguese active when the view executes
# default language active againTranslationSafeTestCase
-----------------------Django `TestCase` subclass which uses `TranslationSafeTestClient` to avoid test failures caused by previous
tests leaving an unexpected locale active.Usage::
from django_i18n_utils.testcases import TranslationSafeTestCase
class MyTestCase(TranslationSafeTestCase):
…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