{"action":"created","issue":{"url":"https://api.github.com/repos/plone/plone.app.multilingual/issues/153","labels_url":"https://api.github.com/repos/plone/plone.app.multilingual/issues/153/labels{/name}","comments_url":"https://api.github.com/repos/plone/plone.app.multilingual/issues/153/comments","events_url":"https://api.github.com/repos/plone/plone.app.multilingual/issues/153/events","html_url":"https://github.com/plone/plone.app.multilingual/issues/153","id":56791505,"number":153,"title":"bad alternate urls when serving with domain","user":{"login":"simahawk","id":347149,"avatar_url":"https://avatars.githubusercontent.com/u/347149?v=3","gravatar_id":"","url":"https://api.github.com/users/simahawk","html_url":"https://github.com/simahawk","followers_url":"https://api.github.com/users/simahawk/followers","following_url":"https://api.github.com/users/simahawk/following{/other_user}","gists_url":"https://api.github.com/users/simahawk/gists{/gist_id}","starred_url":"https://api.github.com/users/simahawk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simahawk/subscriptions","organizations_url":"https://api.github.com/users/simahawk/orgs","repos_url":"https://api.github.com/users/simahawk/repos","events_url":"https://api.github.com/users/simahawk/events{/privacy}","received_events_url":"https://api.github.com/users/simahawk/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/plone/plone.app.multilingual/labels/bug","name":"bug","color":"e10c02"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-06T09:50:04Z","updated_at":"2015-02-11T09:49:22Z","closed_at":null,"body":"When I access a translated content view localhost:port the links are correct. \r\nFor instance, viewing the page `http://localhost:8180/Plone/en/resources/resources-home` the output of `get_alternate_languages` is this:\r\n```\r\n[{'lang': 'ko', 'url': 'resources/resources-home'},\r\n {'lang': 'zh-cn', 'url': 'resources/resources-home'},\r\n {'lang': 'en', 'url': 'resources/resources-home'}, \r\n {'lang': 'ja', 'url': 'resources/resources-home'}]\r\n```\r\nBUT if I access it from a domain (fake or not) like `www.mysite.test/en/resources/resources-home` the output is:\r\n```\r\n[{'lang': 'ko', 'url': 'rces/resources-home'},\r\n {'lang': 'zh-cn', 'url': 'rces/resources-home'}, \r\n {'lang': 'en', 'url': 'rces/resources-home'}, \r\n {'lang': 'ja', 'url': 'rces/resources-home'}]\r\n```\r\nThis happens because the method removes the portal path from the url\r\n\r\nhttps://github.com/plone/plone.app.multilingual/blob/master/src/plone/app/multilingual/browser/viewlets.py#L131\r\n\r\nthat is fine when serving on localhost but when you are serving from domain, the relative url is just fine.\r\n\r\nI'd change the method like this:\r\n```\r\n[...]\r\nportal_path = '/'.join(self.portal_state.portal().getPhysicalPath())\r\nportal_path_len = len(portal_path)\r\nalternates = []\r\nfor item in results:\r\n    url = item.getURL(relative=1)\r\n    path_len = len('{0:s}/'.format(item.Language))\r\n    if url.startswith(portal_path):\r\n        path_len += portal_path_len\r\n    url = url[path_len:]\r\n[...]\r\n```\r\nIs that ok?\r\n"},"comment":{"url":"https://api.github.com/repos/plone/plone.app.multilingual/issues/comments/73855886","html_url":"https://github.com/plone/plone.app.multilingual/issues/153#issuecomment-73855886","issue_url":"https://api.github.com/repos/plone/plone.app.multilingual/issues/153","id":73855886,"user":{"login":"simahawk","id":347149,"avatar_url":"https://avatars.githubusercontent.com/u/347149?v=3","gravatar_id":"","url":"https://api.github.com/users/simahawk","html_url":"https://github.com/simahawk","followers_url":"https://api.github.com/users/simahawk/followers","following_url":"https://api.github.com/users/simahawk/following{/other_user}","gists_url":"https://api.github.com/users/simahawk/gists{/gist_id}","starred_url":"https://api.github.com/users/simahawk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simahawk/subscriptions","organizations_url":"https://api.github.com/users/simahawk/orgs","repos_url":"https://api.github.com/users/simahawk/repos","events_url":"https://api.github.com/users/simahawk/events{/privacy}","received_events_url":"https://api.github.com/users/simahawk/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T09:49:22Z","updated_at":"2015-02-11T09:49:22Z","body":"Here's the commit that fix this https://github.com/plone/plone.app.multilingual/commit/60a9594396a24442d2cdb5420e97adde7223d44d\r\nI ran the alternate test and it's still passing but I'd like to specifically test the case of a \"real\" virtualhost.\r\nDoes anybody know how to fake it properly in tests?"}}