django-modeltranslation icon indicating copy to clipboard operation
django-modeltranslation copied to clipboard

Choices translations are wrong? Why?

Open memegauste opened this issue 4 years ago • 1 comments

At first I must admit that I now use macOS Catalina because my work computer with Linux is not accessable to me because Coronavirus.

So, I have init implementation like this:

    def __init__(self, *args, **kwargs):  # noqa: D107
        self.request = kwargs.pop('request')
        super(HolidayBooking, self).__init__(*args, **kwargs)
        self.fields['employee'].queryset = Employee.active_employees.filter(
            company=self.request.company).exclude(user=self.request.user)
        event_type_choices = [
            (event_type, event_type_name.title())
            for event_type, event_type_name in
            EventType.objects.filter(
                name=EventType.ANNUAL_LEAVE).values_list('id', 'display_name')
            ]
        self.fields['event_type'].choices = event_type_choices

But doing translation like this:

choices=[
            (event_type, event_type_name.title()
             for event_type, event_type_name in
             EventType.objects.values_list('id', 'display_name')),
        ],

Causes the choices being untranslated. Why? Is that system dependent? Or is that bug? Maybe this is caused by Django because it calls lazy functions at the init call?

I don't quite get that.

memegauste avatar Mar 18 '20 10:03 memegauste

I doubt it system dependent. Can you check translation is working fine in some other cases?

last-partizan avatar Mar 19 '20 19:03 last-partizan