First of all, thanks for replies ;)
Bad news: I didn't find a good solution to the problem so far
Good news: there's a "nice" workaround directly from django-modeltranslation
My initial goal was to have every translation field for every language available in dashboard at the same time,
and then use tabs/panes to switch between widgets (if not the page would grow too much with many languages).
If you are ok with leaving this behind, and don't find switching language many times too much frustrating,
everything works "out of the box": if you keep only one translation field at a time (the one that's tied to session language)
and subclass your modelforms using TranslationModelForm everything just works, and saving a product attribute while
under IT locale, will save it in italian, while saving it under EN locale will save it in the other field.
This is definitely NOT the best solution, but requires very little effort and works, even with product attributes.
Some bits of code:
from modeltranslation.translator import translator, TranslationOptions
from .models import Product, Category, ProductAttribute, ProductAttributeValue
class ProductTranslationOptions(TranslationOptions):
fields = ('description',)
class CategoryTranslationOptions(TranslationOptions):
fields = ('description',)
class ProductAttributeTranslationOptions(TranslationOptions):
fields = ('name',)
class ProductAttributeValueTranslationOptions(TranslationOptions):
fields = ('value_text', 'value_richtext')
translator.register(Product, ProductTranslationOptions)
translator.register(Category, CategoryTranslationOptions)
translator.register(ProductAttribute, ProductAttributeTranslationOptions)
translator.register(ProductAttributeValue, ProductAttributeValueTranslationOptions)
from modeltranslation.forms import TranslationModelForm
from oscar.apps.dashboard.catalogue.forms import *
class ProductForm(TranslationModelForm, ProductForm):
This is all it takes to have some catalogue fields translatable (both in admin and in dashboard).
If you don't subclass ProductForm everything is translated except product attributes
(and possibly whatever model has a custom "save()" ), but you have additional fields for every language defined.
Again, this solution is far from optimal, but at least it works and it's very easy.
As soon as I will have some spare time I'll try to get simultaneous translation to work for attributes.
PS: with this approach, a language selector in dashboard is mandatory, or you'll go crazy quite soon ;-)