Package: django-modeltranslation-wrapper
Attention!modeltranslation-0.5has incorporated all features from this app
(moreover, intelligent manager has been improved), so instead of using this app, please update
yourmodeltranslationversion. However, this app is still provided for those who
(for some dark reason) wish to stay with olderMTreleases.This package is a bunch of patches fordjango-modeltranslation(http://code.google.com/p/django-modeltranslation/,http://pypi.python.org/pypi/django-modeltranslation/),
which can enhance usage of this nice app and target some annoying aspects.Two features were added:autodiscover oftranslation.pyfiles within appsmodeltranslation-0.4already has this feature (ported from this app :P), so it is no more
needed here and is only left for use with older versions ofmodeltranslation.
Thus, the autodiscover is deactivated if the 0.4 version ofmodeltranslationis detected.intelligent manager: filtering, ordering, creating and so on takes current language into
consideration(This feature was mainly ported fromdjango-linguo(https://github.com/zmathew/django-linguo,http://pypi.python.org/pypi/django-linguo),
another good app. However,modeltranslationidea oftranslation fieldsregistration is
better thanlinguomodel code edition - especially with 3rd-party apps)Later,modeltranslationwill be referred asMT, anddjango-modeltranslation-wrapperasWrapper.FeaturesAutodiscoverThis app changes the way that the translation files are sought for. InMT, you have
just one file per project.Wrappermakes it more like in theadmin: every application inINSTALLED_APPSis examined and itstranslation.pyis imported (if present).Moreover, if you still want to include some non-app translations (e.g. translation for 3rd-party apps),
there is new setting introduced:MODELTRANSLATION_TRANSLATION_FILES. It should contain list of
additional modules (containing translations) to import.So, when usingWrapper, theMODELTRANSLATION_TRANSLATION_REGISTRYsetting is unnecessary.For backward compatibility withMT, whenMODELTRANSLATION_TRANSLATION_REGISTRYis present,
it is treated as if it was listed inMODELTRANSLATION_TRANSLATION_FILES. So no changes are
required in existing projects usingMT.Intelligent managerWrapperchanges managers in translatable models so that they are aware of active language in their
operations. That means, unsuffixed attributes parameters are rewritten to the suffixed versions.These statements give the same results, assuming current active language ispl:X.objects.filter(foo='bar')
X.objects.filter(foo_pl='bar')

activate('de')
X.objects.filter(foo_pl='bar')  # Still the same resultIf the translatable model has own custom manager, intelligent manager will be gently added,
retaining old functions.TheX.objects.create()is special case, however. For backward compatibility it works as inMTby
default. But you can pass parameter_populate=Trueto populate suffixed fields with
values from unsuffixed ones.Example will clarify it:x = X.objects.create(foo='bar', _populate=True)is equivalent of:x = X.objects.create(foo_en='bar', foo_pl='bar', ... , foo_zu='bar')or:x = X.objects.create(foo='bar')
x.foo_en = 'bar'
x.foo_pl = 'bar'
...
x.foo_zu = 'bar'
x.save()Moreover, some field can be explicitly assigned different value:x = X.objects.create(foo='-- no translation yet --', foo_pl='nic', _populate=True)It will result infoo_pl == 'nic'and otherfoo_??=='--no translation yet--'.There is more convenient way than passing_populateall the time:MODELTRANSLATION_AUTO_POPULATEsetting. If_populateparameter is missing,create()will
look at the setting to determine if population should be used.This useful feature is disabled by default for backward compatibility withMTtests.
However, if your code doesn’t heavily rely on the fact thatcreate()set None on suffixed fields,
it is advised to setMODELTRANSLATION_AUTO_POPULATE = True.New settingsMODELTRANSLATION_TRANSLATION_FILESDefault:()List of additional translation modules to import.MODELTRANSLATION_AUTO_POPULATEDefault:FalseThis setting control ifX.objects.create()function should populate language fields
values.InstallationInstall app:$ pip install django-modeltranslation-wrapperor download it manually and put in python path.Addmodeltranslation_wrappertoINSTALLED_APPSbeforeplainmodeltranslation:INSTALLED_APPS = (
    ...
    'modeltranslation_wrapper',
    'modeltranslation',
    ...
)Optionally, specifyMODELTRANSLATION_TRANSLATION_FILESin settings:MODELTRANSLATION_TRANSLATION_FILES = (
    'myproject.flatpages_translation',
    'myproject.foo_translation',
)These modules will be imported in addition to autodiscovered ones.If you are usingMTin version 0.4 or newer, unfortunatelly you must also add'modeltranslation_wrapper.patch'as last entry inMODELTRANSLATION_TRANSLATION_FILESto enable inteligent manager:MODELTRANSLATION_TRANSLATION_FILES = (
    'myproject.flatpages_translation',
    'myproject.foo_translation',
    'modeltranslation_wrapper.patch',
)This is caused by change in the wayMT0.4 loads translations.Optionally, specifyMODELTRANSLATION_AUTO_POPULATE(see above):MODELTRANSLATION_AUTO_POPULATE = TrueChangelog1.2.2(04/03/2012)Repacked distribution to remove obsoletemodeltranslationspackage, which was previously added by accident.1.2.1(23/09/2012)Refactor code to work with modeltranslation-0.4Update MultilingualManager to rewrite Q nad F queries1.1(04/09/2012)Added testrunner1.0(24/06/2012)Initial codeAuthors:Jacek TomaszewskiZach Mathew (ofdjango-linguo)For details see AUTHORS file.