Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong list of languages for translated fields #375

Open
liminspace opened this issue Jan 20, 2023 · 1 comment
Open

Wrong list of languages for translated fields #375

liminspace opened this issue Jan 20, 2023 · 1 comment

Comments

@liminspace
Copy link

liminspace commented Jan 20, 2023

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.

@DiogoMarques29
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants