deschler / django-modeltranslation

Translates Django models using a registration approach.
BSD 3-Clause "New" or "Revised" License
1.34k stars 257 forks source link

Add a feature to translate the model.fields default value based on field language. #698

Closed bart-maykin closed 10 months ago

bart-maykin commented 11 months ago

Currently when the translation fields are created the default value of a model.field will be translated based on the current value. It would be very handy if this could be changed to the field language of the currently created translation field.

So if you have the following charfield for example: description = models.CharField( verbose_name=_("description"), default=_("Some english text") )

And configured your project to support english and dutch with default (and current) language to be english you get the following fields with values:

 'description': 'Some english text',
 'description_en': 'Some english text',
 'description_nl': 'Some english text',

The wanted outcome would be based on your translation files to something like this for example:

 'description': 'Some english text',
 'description_en': 'Some english text',
 'description_nl': 'Wat nederlandse tekst',
last-partizan commented 11 months ago

Well, that's an interesting feature.

I'm mostly just maintaining this project to ensure it works with latest django versions, but if you're interested, you can try implementing this yourself and create PR, it should be possible to achive you desired result.

sergei-maertens commented 11 months ago

Thank you for the quick feedback! We'll come up with a PR

sergei-maertens commented 10 months ago

@last-partizan hi! we've implemented this feature, can you give an indication on when you (or another maintainer) might have time to review it? I don't mean to pressure you, just having an ETA is sufficient for us to take it into account for our own planning.

last-partizan commented 10 months ago

@sergei-maertens i'll take a look today :)

If everything is ok, expect it merged until the end of the week.

sergei-maertens commented 10 months ago

Awesome!