2010-02-23 14:44:23 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2010-03-02 16:47:19 +00:00
|
|
|
import sys
|
2009-02-17 21:08:19 +00:00
|
|
|
from django.db import models
|
2009-02-17 23:55:17 +00:00
|
|
|
from django.conf import settings
|
2009-02-17 21:08:19 +00:00
|
|
|
from modeltranslation.translator import translator
|
|
|
|
|
|
|
|
|
|
# Every model registered with the modeltranslation.translator.translator
|
|
|
|
|
# is patched to contain additional localized versions for every
|
|
|
|
|
# field specified in the model's translation options.
|
|
|
|
|
|
|
|
|
|
# Import the project's global "translation.py" which registers model
|
|
|
|
|
# classes and their translation options with the translator object.
|
|
|
|
|
try:
|
2010-03-02 15:34:49 +00:00
|
|
|
import translation
|
|
|
|
|
except ImportError:
|
|
|
|
|
sys.stderr.write("modeltranslation: Error can't find the file " \
|
|
|
|
|
"'translation.py' in your project root.\n")
|
|
|
|
|
sys.exit(1)
|
2009-02-17 21:08:19 +00:00
|
|
|
|
|
|
|
|
# After importing all translation modules, all translation classes are
|
2010-02-23 14:44:23 +00:00
|
|
|
# registered with the translator.
|
|
|
|
|
if settings.DEBUG:
|
2010-03-02 16:47:19 +00:00
|
|
|
try:
|
|
|
|
|
if sys.argv[1] in ('runserver', 'runserver_plus'):
|
|
|
|
|
translated_model_names = ', '.join(
|
|
|
|
|
t.__name__ for t in translator._registry.keys())
|
|
|
|
|
print "modeltranslation: Registered %d models for translation " \
|
|
|
|
|
"(%s)." % (len(translator._registry), translated_model_names)
|
|
|
|
|
except IndexError:
|
|
|
|
|
pass
|