Package: django-vinaigrette
django-vinaigretteVinaigrette translates Django model data – stored in the database – using GNU gettext
and Django’s standard internationalization features.InstallingAddvinaigrettetoINSTALLED_APPSin your settings.Then, tell vinaigrette which fields you want to translate. Because vinaigrette needs to register signals,
you should register your model translations when models have finished loading, in the appropriateapps.pyfiles
(or wherever you keep yourAppConfigsubclasses):importvinaigretteclassSaladAppConfig(AppConfig):defready(self):# Import the model requiring translationfrom.modelsimportIngredient# or...Ingredient=self.get_model("Ingredient")# Register fields to translatevinaigrette.register(Ingredient,['name','description'])This tells vinaigrette to translate thenameanddescriptionfields on Ingredient objects.UsingAfter installing vinaigrette, the PO files generated bymanage.py makemessageswill include
strings from the registered fields. If a particular string is translated, the model value will
be the string translated into the appropriate language:>>>fromdjango.utils.translationimportactivate>>>i=Ingredient(name=u'Lettuce')>>>i.nameu'Lettuce'>>>activate('fr')>>>i.nameu'Laitue'Et ceteraThere are a couple of options to restrict which objects translation strings will be collected
from. See the docstring forvinaigrette.register.Vinaigrette adds a--keep-obsoleteoption tomanage.py makemessages, which prevents gettext
from deactivating translated messages no longer present in code or in registered database fields.Vinaigrette is designed for database content that is:always edited in the default languageedited by site administrators, not usersOnly model instances are translated. Data accessed via the Django QuerySetvaluesmethod will
not be translated.In general, when a field is accessed, it will always return the translated version, if one exists.
However, if a value is set, the exact value entered (and not the translated version) should be saved
to the database. For example:>>>fromdjango.utils.translationimportactivate>>>i=Ingredient(name=u'Lettuce')>>>activate('fr')>>>i.nameu'Laitue'>>>i.name='Cabbage'>>>i.nameu'Chou'>>>i.save()>>>Ingredient.objects.get(name='Cabbage').nameu'Chou'Help! The Admin is messing up all the vinaigrette fields whenever I save changes!Addvinaigrette.middleware.VinaigretteAdminLanguageMiddlewareto yoursettings.MIDDLEWAREto force the admin to always use the main language, and
not have vinaigrette mess with your change views.ContributingTestingCreate a virtualenv for the projectInstalltox. When tox is run, it will create the test environments for
supported Django and Python versions and then run tests against themRelease Notes2.0.1Rebuild for PyPI2.0.0Remove Python 2 supportAllow running makemessages without specifying a locale (runs on all
locales)Address Django upgrade warningsEnsure that makemessages works when a non-English locale is active
during its execution1.2.1Fix Python 2 support for makemessagesAdd a test for makemessages1.2.0Added an optional contexts parameter for the register function, for
providing translation context for model fields.Update middleware to the 1.10+ styleMaintains backwards-compat with 1.9 and belowWill now work in eitherMIDDLEWARE_CLASSESorMIDDLEWAREDeprecatesVinaigrettteAdminLanguageMiddlewareforVinaigretteAdminLanguageMiddlewareUsers should change tovinaigrette.middleware.VinaigretteAdminLanguageMiddlewarevinaigrette.VinaigrettteAdminLanguageMiddlewarewill continue to work until next major versionAdds tox and pytest for development and testing1.1.1Update contact info1.1.0Django 2.0 support1.0.1Remembered to update version properly1.0.0Add the--keep-vinaigrette-tempoption which keeps the temporary file containing the generated list of translationsAdded support for Django 1.9Remove support for Django versions < 1.80.5.0Can specify properties to use instead of database field names in .register() function.0.4.0Support for Django 1.70.3.0Support for python 3.3.0.2.0Bug fix for the –all option, it now works again.New VinaigrettteAdminLanguageMiddleware middleware.0.1.3Support for Django 1.6.