跳转到主要内容

本地化Django项目的工具

项目描述

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

数据处理

clean_unicode

utils.clean_unicode接受一个输入字符串并返回规范化的Unicode

UnicodeNormalizerMixin

模型混合类,确保在模型验证的clean_fields步骤中对每个文本字段进行了clean_unicode处理

测试

TranslationSafeTestClient

Django TestClient子类,每次请求后重置活动翻译,以避免测试之间泄漏翻译状态,导致难以调试的副作用,如使用django-modeltranslation加载错误的语言固定数据。

用法

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

TranslationSafeTestCase

Django TestCase子类,使用TranslationSafeTestClient以避免由前一个测试留下的意外区域活动导致的测试失败。

用法

from django_i18n_utils.testcases import TranslationSafeTestCase

class MyTestCase(TranslationSafeTestCase):
    …

LocalizedTestCase

Django TestCase子类,使得创建每个语言的测试变得简单,无需重复或循环。

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

将执行并显示,就像您真的创建了这样

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

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

django-i18n-utils-1.5.3.tar.gz (4.9 kB 查看哈希值)

上传时间 源代码

构建分发

django_i18n_utils-1.5.3-py2.py3-none-any.whl (8.7 kB 查看哈希值)

上传时间 Python 2 Python 3

支持者