Changeset 5255
- Timestamp:
- 05/16/07 07:50:27 (2 years ago)
- Files:
-
- django/branches/unicode/django/contrib/contenttypes/management.py (modified) (2 diffs)
- django/branches/unicode/django/contrib/contenttypes/models.py (modified) (2 diffs)
- django/branches/unicode/django/db/models/options.py (modified) (2 diffs)
- django/branches/unicode/django/utils/translation/__init__.py (modified) (2 diffs)
- django/branches/unicode/django/utils/translation/trans_null.py (modified) (1 diff)
- django/branches/unicode/django/utils/translation/trans_real.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/unicode/django/contrib/contenttypes/management.py
r5240 r5255 5 5 from django.dispatch import dispatcher 6 6 from django.db.models import get_apps, get_models, signals 7 from django.utils.translation import activate, no_trans, get_language8 7 from django.utils.encoding import smart_unicode 9 8 … … 20 19 model=opts.object_name.lower()) 21 20 except ContentType.DoesNotExist: 22 lang = get_language() 23 no_trans() 24 ct = ContentType(name=smart_unicode(opts.verbose_name), 21 ct = ContentType(name=smart_unicode(opts.verbose_name_raw), 25 22 app_label=opts.app_label, model=opts.object_name.lower()) 26 23 ct.save() 27 activate(lang)28 24 if verbosity >= 2: 29 25 print "Adding content type '%s | %s'" % (ct.app_label, ct.model) django/branches/unicode/django/contrib/contenttypes/models.py
r5240 r5255 1 1 from django.db import models 2 from django.utils.translation import ugettext_lazy as _ , no_trans, activate, get_language2 from django.utils.translation import ugettext_lazy as _ 3 3 from django.utils.encoding import smart_unicode 4 4 … … 17 17 # The unicode() is needed around opts.verbose_name because it might 18 18 # be a django.utils.functional.__proxy__ object. 19 lang = get_language()20 no_trans()21 19 ct, created = self.model._default_manager.get_or_create(app_label=key[0], 22 model=key[1], defaults={'name': smart_unicode(opts.verbose_name )})20 model=key[1], defaults={'name': smart_unicode(opts.verbose_name_raw)}) 23 21 CONTENT_TYPE_CACHE[key] = ct 24 activate(lang)25 22 return ct 26 23 django/branches/unicode/django/db/models/options.py
r5126 r5255 6 6 from django.db.models.query import orderlist2sql 7 7 from django.db.models import Manager 8 from django.utils.translation import activate, deactivate_all, get_language 8 9 from bisect import bisect 9 10 import re … … 42 43 self.module_name = self.object_name.lower() 43 44 self.verbose_name = get_verbose_name(self.object_name) 45 46 # There are a few places where the untranslated verbose name is needed 47 # (so that we get the same value regardless of currently active 48 # locale). 49 lang = get_language() 50 deactivate_all() 51 self.verbose_name_raw = unicode(self.verbose_name) 52 activate(lang) 53 44 54 # Next, apply any overridden values from 'class Meta'. 45 55 if self.meta: django/branches/unicode/django/utils/translation/__init__.py
r5240 r5255 9 9 'get_partial_date_formats', 'check_for_language', 'to_locale', 10 10 'get_language_from_request', 'install', 'templatize', 'ugettext', 11 'ungettext', ' no_trans']11 'ungettext', 'deactivate_all'] 12 12 13 13 # Here be dragons, so a short explanation of the logic won't hurt: … … 106 106 return real_templatize(src) 107 107 108 def no_trans():109 return real_ no_trans()108 def deactivate_all(): 109 return real_deactivate_all() 110 110 django/branches/unicode/django/utils/translation/trans_null.py
r5240 r5255 16 16 string_concat = lambda *strings: ''.join([str(el) for el in strings]) 17 17 activate = lambda x: None 18 deactivate = no_trans= install = lambda: None18 deactivate = deactivate_all = install = lambda: None 19 19 get_language = lambda: settings.LANGUAGE_CODE 20 20 get_language_bidi = lambda: settings.LANGUAGE_CODE in settings.LANGUAGES_BIDI django/branches/unicode/django/utils/translation/trans_real.py
r5240 r5255 204 204 del _active[currentThread()] 205 205 206 def no_trans():206 def deactivate_all(): 207 207 """ 208 208 Makes the active translation object a NullTranslations() instance. This is
