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

Change country order based on user language #418

Open
HenryMehta opened this issue Feb 22, 2023 · 1 comment
Open

Change country order based on user language #418

HenryMehta opened this issue Feb 22, 2023 · 1 comment

Comments

@HenryMehta
Copy link

I have a Django app which django-countries. I would like to alter the order of the countries shown based on the user's language. For example if the user is using French, I will bring France, Belgium, Luxumburg, Switzerland etc to the top, whereas if they select German I will bring up Germany, Austria, Switzerland etc.

I can set COUNTRIES_FIRST = ['FR','BE','LU','CH'] within settings, but that ordering is then used for all user languages.

Is there a way to base the order on the user's language?

I have tried modifying the COUNTRIES_FIRST within a view, for example

    if self.administration_instance.study.instrument.language == 'French':
        settings.COUNTRIES_FIRST = ['FR','CH','BE','LU']
    translation.activate(self.user_language)

But this clearly doesn't work

@SmileyChris
Copy link
Owner

There's not a way at the moment to have the countries_first ordered by user language. It'd be an easy addition with a new setting if someone wanted to tackle it!

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

No branches or pull requests

2 participants