2

I have two method detection activated in this order:

1- URL

2- Browser

Problem is that the method "Browser" doesn't work at all if "Cache pages for anonymous users" at 'admin/config/development/performance' is checked. The default language is loaded all the time regardless the Browser language.

It works fine if I uncheck "Cache pages for anonymous users".

See the captures.

enter image description here

enter image description here

1
  • Let me know if I can provide any other information about this.
    – chefnelone
    Nov 3, 2015 at 17:08

2 Answers 2

2
+50

have you seen and tried:

https://stackoverflow.com/questions/22792062/drupal-7-always-redirecting-to-default-language

You might be affected by a bug in Drupal core. I had the same problem for a while and finally found the cause and a workaround for it.

It goes like this:

  1. Add this code to a custom module (change "mymodule" to your modules' name):

    /**
     * Implements hook_language_negotiation_info_alter().
     *
     * Remove the 'cache' setting from LOCALE_LANGUAGE_NEGOTIATION_BROWSER since
     * the code that utilizes this setting will in fact prevent browser negotiation.
     */
    function mymodule_language_negotiation_info_alter(&$negotiation_info) {
        unset($negotiation_info[LOCALE_LANGUAGE_NEGOTIATION_BROWSER]['cache']);
    }
    
  2. Clear all caches (e.g. "drush cc all")

  3. Go to admin/config/regional/language/configure and press "Save settings" once (this will rebuild the variable 'language_negotiation_language').

Now browser language detection should work properly.

I'm also looking for a real solution but this requires changes in core and probably some discussion beforehand because of the nature of the bug. I've opened an issue here: Browser language detection for anonymous requests is broken

there is now a patch from Berdir

0

You need to write custom module to unset the local languages, then it will be sort out your issue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.