mezzanine
mezzanine copied to clipboard
Multible languages in the admin settings tabs are buggy
When using modeltranslation, the translatable fields in the settings tab (Tagline
and Site title
) show the values for all languages in the language the admin uses and not the values from the database.
For example I save Site Title
in English as Shop
and in French as Boutique
.
This is correctly stored in the database.
When I reload the admin if using /en/admin/
it shows for French and English Shop
, but if using /fr/admin/
it shows for French and English Boutique
.
When I change now something else in the Settings
tab, when saving, it stores the currently shown values for Tagline
and Site title
in the database.
So in my example it would store Boutique
for English and French when using the French admin.
Another related issue is, that Order Email Subject
field should be translatable.
For me this is really an annoying bug.
Always when I change something in the Admin settings, I have to restore the translations of Tag line
, Site title
and Order Email Subject
by hand with pgAdmin3
.
@Kniyl Do you have an idea where and how to fix this bug? I could try to fix it but I have no idea where to look.
Hey, I've run into this too, and I'm pretty sure the problem is in mezzanine.conf.forms.SettingsForm._init_field. On line 60, the initial value for these forms is set to gettatr(settings, name) which, because of the magic in django_modeltranslations, always returns the value for the current language.
Also, there's another minor bug where any non-translated settings appearing after a translated setting on this page will be displayed in the last language in settings.LANGUAGES. This is because on line 50 in init for the same form object, activate(active_language) is outside the preceding for loop, and so the language only gets reset to the current language after all fields have been initialized, rather than after each field.
@KagelVlusha Do you want to create a Pull Request? I'm not working with Mezzanine or Django atm.
Pull request created. It's #1773.
My initial assessment of why this happened was a bit wrong. The problem was that the settings object from mezzanine.conf.init only cached values in the user's current language.