=== modified file 'django/contrib/contenttypes/models.py'
|
|
|
85 | 85 | unique_together = (('app_label', 'model'),) |
86 | 86 | |
87 | 87 | def __unicode__(self): |
88 | | return self.name |
| 88 | # self.name is deprecated in favor of using model's verbose_name. |
| 89 | # We return self.name only when users have changed its value from the |
| 90 | # initial verbose_name_raw and might rely on it. |
| 91 | meta = self.model_class()._meta |
| 92 | if self.name != meta.verbose_name_raw: |
| 93 | return self.name |
| 94 | else: |
| 95 | return unicode(meta.verbose_name) |
89 | 96 | |
90 | 97 | def model_class(self): |
91 | 98 | "Returns the Python model class for this type of content." |
=== added directory 'tests/regressiontests/i18n/contenttypes'
=== added file 'tests/regressiontests/i18n/contenttypes/__init__.py'
=== added directory 'tests/regressiontests/i18n/contenttypes/locale'
=== added directory 'tests/regressiontests/i18n/contenttypes/locale/en'
=== added directory 'tests/regressiontests/i18n/contenttypes/locale/en/LC_MESSAGES'
=== added file 'tests/regressiontests/i18n/contenttypes/locale/en/LC_MESSAGES/django.mo'
Binary files tests/regressiontests/i18n/contenttypes/locale/en/LC_MESSAGES/django.mo 1970-01-01 00:00:00 +0000 and tests/regressiontests/i18n/contenttypes/locale/en/LC_MESSAGES/django.mo 2011-09-16 00:09:58 +0000 differ
=== added file 'tests/regressiontests/i18n/contenttypes/locale/en/LC_MESSAGES/django.po'
|
|
|
| 1 | # SOME DESCRIPTIVE TITLE. |
| 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
| 3 | # This file is distributed under the same license as the PACKAGE package. |
| 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 | # |
| 6 | #, fuzzy |
| 7 | msgid "" |
| 8 | msgstr "" |
| 9 | "Project-Id-Version: PACKAGE VERSION\n" |
| 10 | "Report-Msgid-Bugs-To: \n" |
| 11 | "POT-Creation-Date: 2011-09-15 15:41-0700\n" |
| 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
| 15 | "Language: \n" |
| 16 | "MIME-Version: 1.0\n" |
| 17 | "Content-Type: text/plain; charset=UTF-8\n" |
| 18 | "Content-Transfer-Encoding: 8bit\n" |
| 19 | |
| 20 | #: models.py:6 |
| 21 | msgid "Anything" |
| 22 | msgstr "" |
| 23 | |
| 24 | #: models.py:15 |
| 25 | msgid "Company" |
| 26 | msgstr "Company" |
| 27 | No newline at end of file |
=== added directory 'tests/regressiontests/i18n/contenttypes/locale/fr'
=== added directory 'tests/regressiontests/i18n/contenttypes/locale/fr/LC_MESSAGES'
=== added file 'tests/regressiontests/i18n/contenttypes/locale/fr/LC_MESSAGES/django.mo'
Binary files tests/regressiontests/i18n/contenttypes/locale/fr/LC_MESSAGES/django.mo 1970-01-01 00:00:00 +0000 and tests/regressiontests/i18n/contenttypes/locale/fr/LC_MESSAGES/django.mo 2011-09-16 00:09:58 +0000 differ
=== added file 'tests/regressiontests/i18n/contenttypes/locale/fr/LC_MESSAGES/django.po'
|
|
|
| 1 | # SOME DESCRIPTIVE TITLE. |
| 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER |
| 3 | # This file is distributed under the same license as the PACKAGE package. |
| 4 | # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. |
| 5 | # |
| 6 | #, fuzzy |
| 7 | msgid "" |
| 8 | msgstr "" |
| 9 | "Project-Id-Version: PACKAGE VERSION\n" |
| 10 | "Report-Msgid-Bugs-To: \n" |
| 11 | "POT-Creation-Date: 2011-09-15 15:41-0700\n" |
| 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" |
| 13 | "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" |
| 14 | "Language-Team: LANGUAGE <LL@li.org>\n" |
| 15 | "Language: \n" |
| 16 | "MIME-Version: 1.0\n" |
| 17 | "Content-Type: text/plain; charset=UTF-8\n" |
| 18 | "Content-Transfer-Encoding: 8bit\n" |
| 19 | "Plural-Forms: nplurals=2; plural=(n > 1)\n" |
| 20 | |
| 21 | #: models.py:6 |
| 22 | msgid "Anything" |
| 23 | msgstr "" |
| 24 | |
| 25 | #: models.py:15 |
| 26 | msgid "Company" |
| 27 | msgstr "Société" |
| 28 | No newline at end of file |
=== added file 'tests/regressiontests/i18n/contenttypes/tests.py'
|
|
|
| 1 | # coding: utf-8 |
| 2 | import os |
| 3 | |
| 4 | from django.test import TestCase |
| 5 | from django.test.utils import override_settings |
| 6 | from django.utils import translation |
| 7 | from django.contrib.contenttypes.models import ContentType |
| 8 | |
| 9 | |
| 10 | class ContentTypeTests(TestCase): |
| 11 | def test_verbose_name(self): |
| 12 | company_type = ContentType.objects.get(app_label='i18n', model='company') |
| 13 | with translation.override('en'): |
| 14 | self.assertEqual(unicode(company_type), u'Company') |
| 15 | with translation.override('fr'): |
| 16 | self.assertEqual(unicode(company_type), u'Société') |
| 17 | |
| 18 | def test_field_override(self): |
| 19 | company_type = ContentType.objects.get(app_label='i18n', model='company') |
| 20 | company_type.name = 'Other' |
| 21 | self.assertEqual(unicode(company_type), 'Other') |
| 22 | |
| 23 | ContentTypeTests = override_settings( |
| 24 | USE_I18N=True, |
| 25 | LOCALE_PATHS=( |
| 26 | os.path.join(os.path.dirname(__file__), 'locale'), |
| 27 | ), |
| 28 | LANGUAGE_CODE='en', |
| 29 | LANGUAGES=( |
| 30 | ('en', 'English'), |
| 31 | ('fr', 'French'), |
| 32 | ), |
| 33 | )(ContentTypeTests) |
| 34 | No newline at end of file |
=== modified file 'tests/regressiontests/i18n/models.py'
|
|
|
10 | 10 | date_added = models.DateTimeField(default=datetime(1799,1,31,23,59,59,0)) |
11 | 11 | cents_payed = models.DecimalField(max_digits=4, decimal_places=2) |
12 | 12 | products_delivered = models.IntegerField() |
| 13 | |
| 14 | class Meta: |
| 15 | verbose_name = _('Company') |
| 16 | No newline at end of file |
=== modified file 'tests/regressiontests/i18n/tests.py'
|
|
|
26 | 26 | |
27 | 27 | from commands.tests import * |
28 | 28 | from patterns.tests import * |
| 29 | from contenttypes.tests import * |
29 | 30 | from test_warnings import DeprecationWarningTests |
30 | 31 | |
31 | 32 | here = os.path.dirname(os.path.abspath(__file__)) |