{"action":"created","issue":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/5140","labels_url":"https://api.github.com/repos/joomla/joomla-cms/issues/5140/labels{/name}","comments_url":"https://api.github.com/repos/joomla/joomla-cms/issues/5140/comments","events_url":"https://api.github.com/repos/joomla/joomla-cms/issues/5140/events","html_url":"https://github.com/joomla/joomla-cms/pull/5140","id":49430019,"number":5140,"title":"Routing/Language: Refactoring the language system to simplify the code","user":{"login":"Hackwar","id":313866,"avatar_url":"https://avatars.githubusercontent.com/u/313866?v=3","gravatar_id":"","url":"https://api.github.com/users/Hackwar","html_url":"https://github.com/Hackwar","followers_url":"https://api.github.com/users/Hackwar/followers","following_url":"https://api.github.com/users/Hackwar/following{/other_user}","gists_url":"https://api.github.com/users/Hackwar/gists{/gist_id}","starred_url":"https://api.github.com/users/Hackwar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Hackwar/subscriptions","organizations_url":"https://api.github.com/users/Hackwar/orgs","repos_url":"https://api.github.com/users/Hackwar/repos","events_url":"https://api.github.com/users/Hackwar/events{/privacy}","received_events_url":"https://api.github.com/users/Hackwar/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":124,"created_at":"2014-11-19T17:53:43Z","updated_at":"2015-02-09T18:10:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/joomla/joomla-cms/pulls/5140","html_url":"https://github.com/joomla/joomla-cms/pull/5140","diff_url":"https://github.com/joomla/joomla-cms/pull/5140.diff","patch_url":"https://github.com/joomla/joomla-cms/pull/5140.patch"},"body":"The code for the current multi-language system is unnecessarily complex. This PR tries to improve on #5135 and simplify the code further.\r\n\r\n### Goal\r\nThis PR tries to achieve 4 goals:\r\n1. Remove a few inconsistencies in the code that may have resulted in hard-to-find bugs.\r\n2. Improve performance by moving the language-URL-behavior from several different *HelperRoute classes into the single plugin.\r\n3. Allow the routing code to work with the language data where necessary in order to simplify the code there, too.\r\n4. Allow for correct URLs and moving between languages where this is expected.\r\n\r\nEspecially the last part should be discussed in this PR. The new code does not force you to always use one specific language, but allows you to switch between them. The behavior should be the following:\r\n- If a user accesses a site for the first time, the plugin looks up if it should simply direct to the default language or try to discover the right language via the browser.\r\n- The language of the page is always determined by the URL.\r\n- On each pageload, a cookie is set with the current language. If a page has no attached language information, the data from the cookie is taken, otherwise the URL overrides that cookie.\r\n\r\nThis means that a user that surfs a french website and then clicks on a link to a specific english page on the site, the user is not redirected to a french page with the english content inside or an error page or similar.\r\n\r\n### How to test\r\nSimply apply the changes included in here and see that the URLs stay the same and the behavior for language handling is the way you expect it.\r\n\r\n### Routing changes\r\nThe above mentioned routing changes are primarily aimed at easing the code in other parts of Joomla. Currently, a URL is first created via a *HelperRoute class, which replaces the ISO language code from the content item with the corresponding SEF code. The language plugin, which right now is run before every other code in the routing process, takes that SEF code, compares it to the existing SEF codes, looks up the right language for it and then takes the SEF code from that language and adds it as part of the path in the URL. After that, it deletes the language code from the query, so that it is not available to the rest of the routing process anymore. Since the language is an important part of looking up the right Itemid, this means that the lookup of that part has to stay in the *HelperRoute class, instead of moving it to the component router itself.\r\n\r\n### Notice\r\nI changed the above description massively on January 3rd, 2015 in order to make it better understandable. Between opening the PR with the first description and this updated description, the code was again extensively changed and thus the comments before https://github.com/joomla/joomla-cms/pull/5140#issuecomment-65280032 are not valid anymore."},"comment":{"url":"https://api.github.com/repos/joomla/joomla-cms/issues/comments/73558548","html_url":"https://github.com/joomla/joomla-cms/pull/5140#issuecomment-73558548","issue_url":"https://api.github.com/repos/joomla/joomla-cms/issues/5140","id":73558548,"user":{"login":"richard67","id":7413183,"avatar_url":"https://avatars.githubusercontent.com/u/7413183?v=3","gravatar_id":"","url":"https://api.github.com/users/richard67","html_url":"https://github.com/richard67","followers_url":"https://api.github.com/users/richard67/followers","following_url":"https://api.github.com/users/richard67/following{/other_user}","gists_url":"https://api.github.com/users/richard67/gists{/gist_id}","starred_url":"https://api.github.com/users/richard67/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richard67/subscriptions","organizations_url":"https://api.github.com/users/richard67/orgs","repos_url":"https://api.github.com/users/richard67/repos","events_url":"https://api.github.com/users/richard67/events{/privacy}","received_events_url":"https://api.github.com/users/richard67/received_events","type":"User","site_admin":false},"created_at":"2015-02-09T18:10:15Z","updated_at":"2015-02-09T18:10:15Z","body":"Now someone with appropriate privileges has to update test result for @Gitjk and reset those of @anibalsanchez and @dgt41, and test count is ok.<hr /><sub>This comment was created with the <a href=\"https://github.com/joomla/jissues\">J!Tracker Application</a> at <a href=\"http://issues.joomla.org/tracker/joomla-cms/5140\">issues.joomla.org/joomla-cms/5140</a>.</sub>"}}