equal
deleted
inserted
replaced
|
1 |
|
2 from django.db import models |
|
3 from django.conf import settings |
|
4 |
|
5 from modeltranslation.translator import translator |
|
6 |
|
7 # Every model registered with the modeltranslation.translator.translator |
|
8 # is patched to contain additional localized versions for every |
|
9 # field specified in the model's translation options. |
|
10 |
|
11 # Import the project's global "translation.py" which registers model |
|
12 # classes and their translation options with the translator object. |
|
13 # This requires an extra settings entry, because I see no other way |
|
14 # to determine the module name of the project |
|
15 try: |
|
16 translation_mod = __import__(settings.TRANSLATION_REGISTRY, {}, {}, ['']) |
|
17 except ImportError, exc: |
|
18 print "No translation.py found in the project directory." |
|
19 #raise ImportError("No translation.py found in the project directory.") |
|
20 |
|
21 # After importing all translation modules, all translation classes are |
|
22 # registered with the translator. |
|
23 translated_app_names = ', '.join(t.__name__ for t in translator._registry.keys()) |
|
24 print "modeltranslation: registered %d applications for translation (%s)." % (len(translator._registry), |
|
25 translated_app_names) |