infoportugal/wagtail-modeltranslation

Wrong list of languages for translated fields

Opened this issue · 1 comments

If MODELTRANSLATION_LANGUAGES is set, it must be used instead of LANGUAGES.
I found it in the translated_slugs function but looks like this issue is global.
For example, I have a website with 5 languages of admin interface (they are set in LANGUAGES) but only 3 languages are used in content (they are set in MODELTRANSLATION_LANGUAGES).
Following the django-modeltranslation package, the best way is:

content_languages = tuple(
    getattr(
        settings,
        "MODELTRANSLATION_LANGUAGES",
        [item[0] for item in settings.LANGUAGES],
    )
)

This list of languages must be used in all places where the list of languages for translated fields is used.
I see it's implemented in AVAILABLE_LANGUAGES of the modeltranslation.settings, so it just can be used.

In the django-modeltranslation code, we can see:

AVAILABLE_LANGUAGES = list(
    getattr(
        settings,
        "MODELTRANSLATION_LANGUAGES",
        (val for val, label in settings.LANGUAGES),
    )
)

If MODELTRANSLATION_LANGUAGES is not defined, it will use the list of LANGUAGES. So, we should replace LANGUAGES for AVAILABLE_LANGUAGES, do you agree?