Translations handling cleanup (with performance boost, too)
|Reported by:||Anssi Kääriäinen||Owned by:||Anssi Kääriäinen|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
The attached patch implements a different way to handle the delayed translations handling. The idea is to use a class and a getattr based method instead of using the delayed_loader and manipulating the globals.
The only problem with this patch is that if settings.USE_I18N is changed dynamically, the change setting will not change which function (the trans_null or trans_real one) is called. For normal use this is only a good thing (dynamical settings changing is evil), but can cause some problems if testing relies on this. If this is a problem, the class based method can easily be changed to not cache the functions. Just remove the setattr from the getattr method of the TransProvider.
The patch passes all tests.