Amazing timing for me -- client just requested this functionality and here's your module! Thanks for putting this together!
I just found a possible bug..
My site uses user's browser language settings for language detection. I disabled removed anonymous user access to Spanish, leave it on for English and Russian. When a user with a browser language of Spanish comes to the site, I think they are being redirected to /es/, but since they don't haves permission to access Spanish, I think they are redirected back to / .. which then causes a redirect to /es/ again. So browser reports a "too many redirects" error.
Any possibility of influencing the language detection settings with this module?
Comments
Comment #1
Jānis Bebrītis commentedI was aware of the fact that at least default language should be accessible for that specific role. Usually it happens that there should be at least one visible language for anonymous user.
Let's see how we can solve this -
As a workaround I see 3 options:
- it could fall back to "/[default-lang]" instead of "/". That should do it for lang detection mode.
- module settings with drupal path for fallback
- die('Error #'.rand());
Comment #2
jonmcl commentedI like the first option: "/[default-lang]" instead of "/"
Technically it should take the next preferred language that the client has access to, but I think this would be a good compromise. Most sites (mine included) have a way to select a language anyway. So if client browser preference is for ES->RU->EN, but my default language is EN, they would get EN (for a site with EN & RU). Not perfect, but I think it's acceptable.
..jon
Comment #3
Jānis Bebrītis commentedShould be fixed in dev now. You can checkout code from git and test. Will be packed as tar.gz on d.o. in day or two.
Comment #4
jonmcl commentedWorks perfectly!!
Thank you!!
..jon
Comment #5
jonmcl commentedForgot to update status.
Comment #6
shadysamir commentedI am getting the too many redirects issue with the latest dev.
Default language "ar", detection is URL prefix then default, "ar" has no prefix defined. Only logged in users can view "en". Anonymous user get Too Many Redirects trying to open example.com/en
Comment #7
Jānis Bebrītis commentedI think this is related to issue here #1705122: No permissions set on install
Problem is - if anonymous user has no permission to access at least default language, he get's redirect loop. Felix has even supplied patch for it.
Comment #8
Jānis Bebrītis commentedAll fixed, there is default_language check now. Also, there are no funky drupal_goto's anymore, it's drupal_access_denied + exit instead;