language-specific translation for default field
I'm writing an app which has translation for en and fa.
I've added content to translation fields, when I want to add a post to my app it shows me same translated "My default value" for both en and fa based on current active language. But I want it to be based on field language.
content = models.TextField(_("Session description"), default=_("My default value"))
What I should do to fix this issue?
I'm afraid modeltranslation doesn't support this currently. It makes sense however and i think we should try to add it as the default behaviour.
Committed a first try in 52e24d6. It might need some additional work, since default can also be a callable. And it requires a unittest.
Thanks for your attention and support :+1:
@zlorf: What do you think about this feature? Do you see any conflicts it might raise with our fallbacks?
@deschler: I'm currently on a vacation, I'll take a look a bit later. ;)
@deschler It seems ok. I've tried fallback values and it works. But I fear that it may fail with fallback languages. Values in database would be different for each language field (text_en and text_de, for example), and when checking fallback in descriptor one of these fields will yield value different from current default (computed once for against current active language). The solution would be to compute default (or rather undefined) separately for each checked fallback language (https://github.com/deschler/django-modeltranslation/blob/override-default/modeltranslation/fields.py#L337), not once (https://github.com/deschler/django-modeltranslation/blob/override-default/modeltranslation/fields.py#L331)
Sorry I was busy for a while so I couldn't test this, now I'm back.
I guess this feature isn't in 0.8b2 release, also tried to install package using
pip install git+git://github.com/deschler/django-modeltranslation.git
and it's still same thing, is it possible to release a new version which includes this feature?
Hello @deschler, Having translated defaults values is a logical feature to have (thanks @k1-hedayati ), I'm happy you guys worked on it. Shall We initiate a PR for the override-default branch ?