? Success

User tests: Successful: Unsuccessful:

avatar Bakual
Bakual
15 Mar 2015

Issue

There is currently an issue that the cookie setting isn't respected when you access www.example.com. If you visited the site before and switched the language, it should actually redirect you to that language but it currently will always redirect to the site default language.

Solution

There are already several PRs which are trying to solve this issue. Most of the did detect a part of the problem, but missed another part.
So this is my attemp to merge the best from various PRs to try to get this solved. Hopefully I didn't miss anything myself :smile:
What I did:

  • From #6428 I took the fix for the cookie_path, which now defaults just to / like we do in all other instances where we set a cookie within our CMS.
  • From #6230 I took the fix to detect the cookie language properly
  • Additional I fixed the buildRule so it allows to switch back to the default language. Basically the language code is added to the URL if the current language isn't the default language, allowing to switch back and override the cookie setting. Also I'm setting the cookie before the redirect in that case.

Testing

  • Set up a multilanguage site and enable SEF with mod_rewrite.
  • Try with and without the setting "Remove language code for default language" in the languagefilter plugin
  • When accessing www.example.com the first time, you should be redirected to the default language content.
  • When you switch the language, you should see the selected language and the URL changed to www.example.com/de (if you switched to german).
  • Now the tricky part comes: Try to reload www.example.com. You should be redirected to the language you selected before (www.example.com/de/), but this fails currently and you get redirected to site default language again.
  • Apply patch and clear the language cookies. Simplest is to just close all instances of your chosen browser. The language cookies is limited to session by default.
  • Now the redirects should work as expected.
avatar Bakual Bakual - open - 15 Mar 2015
avatar joomla-cms-bot joomla-cms-bot - change - 15 Mar 2015
Labels Added: ?
avatar Bakual
Bakual - comment - 15 Mar 2015

(Hopefully) fixed codestyle and removed some unneeded code based on suggestions from Hannes. Thanks!

avatar infograf768
infograf768 - comment - 16 Mar 2015

@test

Much better! Now cookie works OK with URL Language Code removed.

I still get an issue here
Settings:
1. Browser set to en-gb as preferred language
2. Default site language set to fr-FR
3. Settings for Global Configuration:

screen shot 2015-03-16 at 08 35 38

  1. Settings for Languagefilter plugin. screen shot 2015-03-16 at 08 33 24

Delete all cookies. Quit browser. Relaunch browser. Enter tld root.
Result: the site default language loads (fr-FR) instead of the Browser setttings language (en-GB)

This happens only when url language code is removed.

avatar infograf768
infograf768 - comment - 16 Mar 2015

Tested with this code:

// If the default prefix should be removed and the SEF prefix is not among those
            // that we have in our system, its the default language and we "found" the right language
            if ($this->params->get('remove_default_prefix', 0) && !isset($this->sefs[$sef]))
            {
                $lang_code = $this->app->input->cookie->getString(
                    JApplicationHelper::getHash('language')
                );

                if (!$lang_code && $this->params->get('detect_browser', 0) == 1)
                {
                    $lang_code = JLanguageHelper::detectLanguage();
                }

                if (!$lang_code)
                {
                    $lang_code = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
                }

                if ($lang_code == JComponentHelper::getParams('com_languages')->get('site', 'en-GB'))
                {
                    $found = true;
                }
            }
            else
[...]

and looks like it corrects the issue here.

avatar Bakual
Bakual - comment - 16 Mar 2015

Added suggestion by @infograf768. Worked when I tested it.

avatar infograf768
infograf768 - comment - 16 Mar 2015

@test
Works fine for me. Including correct urls obtained by the langswitcher.

avatar gwsdesk
gwsdesk - comment - 16 Mar 2015

@test works for me also. Get the correct url's

avatar brianteeman brianteeman - change - 16 Mar 2015
Category Authentication Multilanguage
avatar Kubik-Rubik
Kubik-Rubik - comment - 16 Mar 2015

Great contribution @Bakual!

Let's get the new version done and released!

avatar Kubik-Rubik Kubik-Rubik - close - 16 Mar 2015
avatar Kubik-Rubik Kubik-Rubik - reference | - 16 Mar 15
avatar Kubik-Rubik Kubik-Rubik - merge - 16 Mar 2015
avatar Kubik-Rubik Kubik-Rubik - close - 16 Mar 2015
avatar Kubik-Rubik Kubik-Rubik - change - 16 Mar 2015
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2015-03-16 13:48:16
avatar Kubik-Rubik Kubik-Rubik - change - 16 Mar 2015
Milestone Added:
avatar Bakual Bakual - head_ref_deleted - 16 Mar 2015
avatar xpallicer
xpallicer - comment - 23 Mar 2015

This issue has not been fixed, cookie language is not remembered

avatar infograf768
infograf768 - comment - 23 Mar 2015

@xpallicer
You should test on 3.4.1 and make sure to tick Year for the cookie time in the languagefilter, so that the cookie still exists after quitting the browser and relaunching.

avatar xpallicer
xpallicer - comment - 23 Mar 2015

Hello infograf,
Did this: update to Joomla 3.4.1, delete all site's cookies. Access mysite.com/es, access mysite.com I get redirected to my browser default language (I should be redirected to mysite.com/es again)

avatar infograf768
infograf768 - comment - 23 Mar 2015

After accessing mysite.com/es, quit the browser and then relaunch and use mysite.com

avatar xpallicer
xpallicer - comment - 23 Mar 2015

Now it works. I think the bug persists if you do not update (save) Joomla global configuration. Thank you. Best regards!

avatar Bakual
Bakual - comment - 23 Mar 2015

The config don't matter. What is important is that you cleared the cookies. Especially the one with the path set to something else than / (root) :smile:

avatar pjwiseman pjwiseman - alter_testresult - 27 Mar 2015 - infograf768: Tested successfully
avatar pjwiseman pjwiseman - alter_testresult - 27 Mar 2015 - gwsdesk: Tested successfully
avatar chrisxchrisxchrisx
chrisxchrisxchrisx - comment - 13 Jul 2015

I cannot get this to work under 3.4.3 as it used to under 3.1.5 (yes I had put off upgrading for some time since initial upgrade failed). I followed this process:

  1. Using Firefox 39.0 clear all cookies

  2. Check Language Filter settings via http://saatalk.info/administrator
    Language Selection for new Visitors: Browser Settings
    Automatic Language Change: Yes
    Item Associations: Yes
    Remove URL Language Code: No
    Cookie Lifetime: Year
    Add Alternate Meta Tags: Yes

  3. Check http://saatalk.info
    Correctly redirected to http://saatalk.info/en in line with browser settings
    Cookie containing en-GB stored on path /

  4. Select Deutsch via language switcher on http://saatalk.info
    Correctly redirected to http://saatalk.info/de
    Cookie containing de-DE stored on path /

  5. Check http://saatalk.info
    INCORRECTLY redirected to http://saatalk.info/en
    Cookie containing en-GB stored on path /

What I want to happen is for the language to be specified by the following in order of priority:
1. via the URL
2. via the Language Switcher
3. via the Browser Settings

This is indeed what happened under 3.1.5 and reading about the clever work done in this thread I thought it was what you guys were aiming at too. Now it seems to be ignoring point 2 entirely, and the Language Switcher just sets the the URL in menu items, ignoring the cookie entirely for any other URL without a language specification. Am I still doing something wrong?

avatar Bakual
Bakual - comment - 13 Jul 2015
  1. via the URL
  2. via the Language Switcher
  3. via the Browser Settings

The language switcher is the same as "URL". So you either have "URL" or "browser settings". URL obviously has priority over browser settings.
What you mean is the cookie value which gets ignored. But only if Remove URL Language Code is disabled. If it's enabled all seem to work fine.

@chrisxchrisxchrisx
Can you please open a new issue? Because it will not get fixed when you comment on a closed PR.

Add a Comment

Login with GitHub to post a comment