{"action":"created","issue":{"url":"https://api.github.com/repos/plone/plone.api/issues/379","repository_url":"https://api.github.com/repos/plone/plone.api","labels_url":"https://api.github.com/repos/plone/plone.api/issues/379/labels{/name}","comments_url":"https://api.github.com/repos/plone/plone.api/issues/379/comments","events_url":"https://api.github.com/repos/plone/plone.api/issues/379/events","html_url":"https://github.com/plone/plone.api/issues/379","id":247403791,"number":379,"title":"portal.get_current_language does not negotiate for language variants","user":{"login":"fredvd","id":394784,"avatar_url":"https://avatars2.githubusercontent.com/u/394784?v=4","gravatar_id":"","url":"https://api.github.com/users/fredvd","html_url":"https://github.com/fredvd","followers_url":"https://api.github.com/users/fredvd/followers","following_url":"https://api.github.com/users/fredvd/following{/other_user}","gists_url":"https://api.github.com/users/fredvd/gists{/gist_id}","starred_url":"https://api.github.com/users/fredvd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredvd/subscriptions","organizations_url":"https://api.github.com/users/fredvd/orgs","repos_url":"https://api.github.com/users/fredvd/repos","events_url":"https://api.github.com/users/fredvd/events{/privacy}","received_events_url":"https://api.github.com/users/fredvd/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-08-02T14:14:02Z","updated_at":"2017-08-03T22:19:55Z","closed_at":null,"body":"Debugging this with @mauritsvanrees this afternoon:\r\n\r\nportal.translate depends on portal.get_current_language to pass the current language to the translate function.  get_current_language its docstring says   \"\"\"Return the current negotiated language.\"\"\", but it does not do any negotiation as it is provided by zope.i18n.negotiate. \r\n\r\nThis causes Plone sites with a configured language variante like nl-be (Flemish), not to fallback to 'nl' for fetching the Dutch translation.  Although portal.translate eventually calls zope.i18n.translate, the context is no longer available and the target_language is set to 'nl-be', for which no .po files can be found. zope.i18n.translate does not call negotiate if target_language is set explicitly and no context is found.\r\n\r\nProposed solution is to call zope.i18n's negotiate function, this would do what the docstring promises. But meanwhile other code might depend on get_current_language fetching the actual language on the request, which may or may not be a variant. \r\n\r\nSo maybe portal.translate should not use get_current_language but call a new get_current_translation_language\r\n\r\nA related feature could be to allow passing in the request object into the translate function, then it is not necessary to set target_language. \r\n\r\n@ebrehault @jensens @rnixx You've been working on these plone.api methods in the past and have some experience with this, is the above a correct analysis? \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/plone/plone.api/issues/comments/320105501","html_url":"https://github.com/plone/plone.api/issues/379#issuecomment-320105501","issue_url":"https://api.github.com/repos/plone/plone.api/issues/379","id":320105501,"user":{"login":"jensens","id":157140,"avatar_url":"https://avatars1.githubusercontent.com/u/157140?v=4","gravatar_id":"","url":"https://api.github.com/users/jensens","html_url":"https://github.com/jensens","followers_url":"https://api.github.com/users/jensens/followers","following_url":"https://api.github.com/users/jensens/following{/other_user}","gists_url":"https://api.github.com/users/jensens/gists{/gist_id}","starred_url":"https://api.github.com/users/jensens/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jensens/subscriptions","organizations_url":"https://api.github.com/users/jensens/orgs","repos_url":"https://api.github.com/users/jensens/repos","events_url":"https://api.github.com/users/jensens/events{/privacy}","received_events_url":"https://api.github.com/users/jensens/received_events","type":"User","site_admin":false},"created_at":"2017-08-03T22:19:55Z","updated_at":"2017-08-03T22:19:55Z","body":"I agree with @gforcada. Also, I think a major version bump is a must, even if this is a fix. But one changing behavior."}}
{"actor":{"display_login":"jensens"}}