{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/7096","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/7096/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/7096/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/7096/events","html_url":"https://github.com/joomla/joomla-cms/pull/7096","id":84030219,"number":7096,"title":"Fix browser language detection (for mono-lingual sites)","user":{"login":"smz","id":552475,"avatar_url":"https://avatars.githubusercontent.com/u/552475?v=3","gravatar_id":"","url":"https://api.github.com/users/smz","html_url":"https://github.com/smz","followers_url":"https://api.github.com/users/smz/followers","following_url":"https://api.github.com/users/smz/following{/other_user}","gists_url":"https://api.github.com/users/smz/gists{/gist_id}","starred_url":"https://api.github.com/users/smz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smz/subscriptions","organizations_url":"https://api.github.com/users/smz/orgs","repos_url":"https://api.github.com/users/smz/repos","events_url":"https://api.github.com/users/smz/events{/privacy}","received_events_url":"https://api.github.com/users/smz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/joomla/joomla-cms/labels/PR-staging","name":"PR-staging","color":"c7def8"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":30,"created_at":"2015-06-02T13:46:31Z","updated_at":"2015-06-06T06:20:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/7096","html_url":"https://github.com/joomla/joomla-cms/pull/7096","diff_url":"https://github.com/joomla/joomla-cms/pull/7096.diff","patch_url":"https://github.com/joomla/joomla-cms/pull/7096.patch"},"body":"#### Steps to reproduce the issue\r\n- start installing a **non multilingual** (*i.e. language filter not published*) site from staging code to which you will add some more languages (*but* **not** *as content languages*): at least one matching and one **not** matching your browser language\r\n- set a language that doesn't match your browser as the site default language (*and as the* **only** *content language*)\r\n- in language filter set \"*Language Selection for new Visitors*\" to \"*Browser settings*\"\r\n- visit your site\r\n\r\n#### Expected result\r\nJoomla strings (*not content, of course...*) should be displayed in your browser language\r\n\r\n#### Actual result\r\nJoomla strings are displayed in the site default language\r\n\r\n#### The causes of the issue\r\n- in `JApplicationSite::initialiseApp()` browser detection is performerd only if `$this->_detect_browser` is `true`, but this cannot happen at this stage as it is initialized by the language filter\r\n- `JLanguageHelper::detectLanguage()` gets the list of available languages from `self::getLanguages()`, but for non-multilingual sites that returns just the site default language\r\n- additionally you might have an `en-US` browser and the site only have `en-GB` as an English language: `en-US` will not be recognized and you'll be presented with the site default language (e.g. `it-IT`)\r\n\r\n#### What this PR does\r\n- it streamlines `JApplicationSite::initialiseApp()` by removing unnecessary code (*e.g.: reading the cookie, as this method is only meant to initialize language stuff for* **non-multilingual** *sites*) and correct the logic to detect if \"*Browser settings*\" is set.\r\n- the above required introducing a new `JLanguageMultilang::isSetDetectBrowser()` public method\r\n- a correction introduced in #7091 (closed) has been brought forward\r\n- `JLanguageHelper::detectLanguage()` has been rewritten so that it matches available languages also on the basis of the language prefix (*i.e.: if you have an* `en-US` *browser, and only* `en-GB` *and* `it-IT (default)` *are available, you'll be offered* `en-GB` *and not* `it-IT`). I think that makes sense.\r\n\r\n#### Testing procedure\r\n- Apply this patch and verify that the issue is corrected\r\n- Additionally check that everything is OK with multi-lingual sites too\r\n\r\n#### Additional comments\r\nThanks @Hackwar whom #6309 inspired this."},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/109535751","html_url":"https://github.com/joomla/joomla-cms/pull/7096#issuecomment-109535751","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/7096","id":109535751,"user":{"login":"infograf768","id":869724,"avatar_url":"https://avatars.githubusercontent.com/u/869724?v=3","gravatar_id":"","url":"https://api.github.com/users/infograf768","html_url":"https://github.com/infograf768","followers_url":"https://api.github.com/users/infograf768/followers","following_url":"https://api.github.com/users/infograf768/following{/other_user}","gists_url":"https://api.github.com/users/infograf768/gists{/gist_id}","starred_url":"https://api.github.com/users/infograf768/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/infograf768/subscriptions","organizations_url":"https://api.github.com/users/infograf768/orgs","repos_url":"https://api.github.com/users/infograf768/repos","events_url":"https://api.github.com/users/infograf768/events{/privacy}","received_events_url":"https://api.github.com/users/infograf768/received_events","type":"User","site_admin":false},"created_at":"2015-06-06T06:20:07Z","updated_at":"2015-06-06T06:20:07Z","body":"I guess we can close this one to not confuse testers."}}