{"action":"created","issue":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/14088","repository_url":"https://api.github.com/repos/Automattic/wp-calypso","labels_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/14088/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/14088/comments","events_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/14088/events","html_url":"https://github.com/Automattic/wp-calypso/pull/14088","id":228928941,"number":14088,"title":"Supply the browser language setting if the current user locale is not available.","user":{"login":"southp","id":1842898,"avatar_url":"https://avatars3.githubusercontent.com/u/1842898?v=3","gravatar_id":"","url":"https://api.github.com/users/southp","html_url":"https://github.com/southp","followers_url":"https://api.github.com/users/southp/followers","following_url":"https://api.github.com/users/southp/following{/other_user}","gists_url":"https://api.github.com/users/southp/gists{/gist_id}","starred_url":"https://api.github.com/users/southp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/southp/subscriptions","organizations_url":"https://api.github.com/users/southp/orgs","repos_url":"https://api.github.com/users/southp/repos","events_url":"https://api.github.com/users/southp/events{/privacy}","received_events_url":"https://api.github.com/users/southp/received_events","type":"User","site_admin":false},"labels":[{"id":285009982,"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/API","name":"API","color":"bfdadc","default":false},{"id":285010027,"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/i18n","name":"i18n","color":"bfdadc","default":false},{"id":542869111,"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Size]%20S","name":"[Size] S","color":"aa71a7","default":false},{"id":285010030,"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Status]%20Ready%20to%20Merge","name":"[Status] Ready to Merge","color":"d4fb79","default":false},{"id":285009976,"url":"https://api.github.com/repos/Automattic/wp-calypso/labels/[Type]%20Enhancement","name":"[Type] Enhancement","color":"c7def8","default":false}],"state":"open","locked":false,"assignee":{"login":"southp","id":1842898,"avatar_url":"https://avatars3.githubusercontent.com/u/1842898?v=3","gravatar_id":"","url":"https://api.github.com/users/southp","html_url":"https://github.com/southp","followers_url":"https://api.github.com/users/southp/followers","following_url":"https://api.github.com/users/southp/following{/other_user}","gists_url":"https://api.github.com/users/southp/gists{/gist_id}","starred_url":"https://api.github.com/users/southp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/southp/subscriptions","organizations_url":"https://api.github.com/users/southp/orgs","repos_url":"https://api.github.com/users/southp/repos","events_url":"https://api.github.com/users/southp/events{/privacy}","received_events_url":"https://api.github.com/users/southp/received_events","type":"User","site_admin":false},"assignees":[{"login":"southp","id":1842898,"avatar_url":"https://avatars3.githubusercontent.com/u/1842898?v=3","gravatar_id":"","url":"https://api.github.com/users/southp","html_url":"https://github.com/southp","followers_url":"https://api.github.com/users/southp/followers","following_url":"https://api.github.com/users/southp/following{/other_user}","gists_url":"https://api.github.com/users/southp/gists{/gist_id}","starred_url":"https://api.github.com/users/southp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/southp/subscriptions","organizations_url":"https://api.github.com/users/southp/orgs","repos_url":"https://api.github.com/users/southp/repos","events_url":"https://api.github.com/users/southp/events{/privacy}","received_events_url":"https://api.github.com/users/southp/received_events","type":"User","site_admin":false}],"milestone":null,"comments":3,"created_at":"2017-05-16T06:36:18Z","updated_at":"2017-05-17T06:27:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Automattic/wp-calypso/pulls/14088","html_url":"https://github.com/Automattic/wp-calypso/pull/14088","diff_url":"https://github.com/Automattic/wp-calypso/pull/14088.diff","patch_url":"https://github.com/Automattic/wp-calypso/pull/14088.patch"},"body":"## Summary\r\n\r\nCurrently, for all api requests initiated from a logged-out session, the locale parameter will be absent since there is no current user. This PR aims to supply the browser language setting in this case, so that these requests can carry proper localization info.\r\n\r\n## Test Plan\r\n\r\nFrom what I know, one easy way to initiate some logged-out api requests is through the account recovery process, so let's piggy-back on it.\r\n\r\n### Logged-out session\r\n1. Visit http://calypso.localhost:3000/account-recovery, enter a test account, and hit \"Continue\"\r\n1. From there, a GET request to `/account-recovery/lookup` should be fired. On this branch, it should carry a `locale` query argument:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/1842898/26092703/fd340c50-3a44-11e7-89f0-f51496e79609.png)\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Automattic/wp-calypso/issues/comments/301997887","html_url":"https://github.com/Automattic/wp-calypso/pull/14088#issuecomment-301997887","issue_url":"https://api.github.com/repos/Automattic/wp-calypso/issues/14088","id":301997887,"user":{"login":"southp","id":1842898,"avatar_url":"https://avatars3.githubusercontent.com/u/1842898?v=3","gravatar_id":"","url":"https://api.github.com/users/southp","html_url":"https://github.com/southp","followers_url":"https://api.github.com/users/southp/followers","following_url":"https://api.github.com/users/southp/following{/other_user}","gists_url":"https://api.github.com/users/southp/gists{/gist_id}","starred_url":"https://api.github.com/users/southp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/southp/subscriptions","organizations_url":"https://api.github.com/users/southp/orgs","repos_url":"https://api.github.com/users/southp/repos","events_url":"https://api.github.com/users/southp/events{/privacy}","received_events_url":"https://api.github.com/users/southp/received_events","type":"User","site_admin":false},"created_at":"2017-05-17T06:27:06Z","updated_at":"2017-05-17T06:27:06Z","body":">  is the initial page load translation being taken care somewhere else? \r\n\r\n@yoavf Argh, that's a very good question.\r\nWhen I visit `wordpress.com` without logging in, I will be redirected to `zh-tw.wordpress.com` and everything followed will be localized like you said. However, if it is my local calypso instance, I don't see an obvious way to trigger this locale changing behavior for logged-out session.\r\n\r\nAfter some experiments, it seems to be controlled by [the lang property](https://github.com/Automattic/wp-calypso/blob/master/server/pages/index.js#L140) of the server render context object. At first, I thought updating `i18n_default_locale` as `zh-tw` via my `development.local.json` would do the trick, but it didn't work for me. In the end, I had to hard code that line as `lang: 'zh-tw'` and made sure `i18n_default_locale` flag is not `zh-tw`, otherwise the locale change wouldn't be triggered ... weird.\r\n\r\nAnyway, I think what we put as the `locale` parameter should be consistent with what the user is seeing. e.g. in my case, since I have been redirected to `zh-tw.wordpress.com`, the locale parameter should be `zh-tw`.\r\n\r\nIn that case, is `navigator.language` still a good candidate? or, is there a way we can obtain this locale info?"}}
{"actor":{"display_login":"southp"}}