-
Notifications
You must be signed in to change notification settings - Fork 57
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
Auto-detect language #121
Comments
Good idea. But I don’t think you have to struggle with webserver configuration, as it can be done with JavaScript like here. Then we can just make a JS file redirecting us to the right language. Something like this: var browserlang = navigator.language || navigator.userLanguage;
if (browserlang.includes('en')) { window.location = '/en/'; }
if (browserlang.includes('fr')) { window.location = '/fr/'; } Of course, you’ll have to execute this code ONLY on the site’s There’s one disadvantage: the JS code will be executed in the user’s browser. When the user has disabled JavaScript execution, this script doesn’t work. |
If we put this code on the default language's index to be on |
@victorbnl You’re right, otherwise you can make a site detect the user’s language and if the user hasn’t selected that language, show a friendly dialog. E.g. as Apple does: |
I'd say that's not a solution, that's an awful user-experience, the goal would be to just display directly the correct page to the user |
I'm using polyglot for a bilingual (French and English) site. Currently the default_lang is en. I would like the site to auto-detect the user's preferred language, probably via the
Accept-Language
header. Discussion in this Issue suggests that this can be achieved via webserver configuration, by redirecting to the appropriate localized version of the deployed site based on inspecting the header. I'm open to that. However, there is currently no convenient/elegant path for me to do this. That's because I'm running thenginx
webserver, and the relevant module requires me to recompilenginx
. I can do that, but it would imply missing out onnginx
updates from the distribution vendor (Ubuntu in my case).Opening a new issue as suggested by @untra .
The text was updated successfully, but these errors were encountered: