{"action":"created","comment":{"url":"https://api.github.com/repos/freedombox/Plinth/pulls/comments/45550937","id":45550937,"diff_hunk":"@@ -51,6 +53,16 @@ def get_domainname():\n     return '.'.join(fqdn.split('.')[1:])\n \n \n+def get_language(request):\n+    \"\"\"Return the current language setting\"\"\"\n+    # TODO: Store the language per user in kvstore,\n+    # taking care of setting language on login, and adapting kvstore when\n+    # renaming/deleting users\n+\n+    # The session contains more accurate information than request.LANGUAGE_CODE\n+    return request.session[translation.LANGUAGE_SESSION_KEY]","path":"plinth/modules/config/config.py","position":21,"original_position":21,"commit_id":"aeaa6ab800a8f91579c9fa89ea3d6a86404829d3","original_commit_id":"aeaa6ab800a8f91579c9fa89ea3d6a86404829d3","user":{"login":"jvalleroy","id":178876,"avatar_url":"https://avatars.githubusercontent.com/u/178876?v=3","gravatar_id":"","url":"https://api.github.com/users/jvalleroy","html_url":"https://github.com/jvalleroy","followers_url":"https://api.github.com/users/jvalleroy/followers","following_url":"https://api.github.com/users/jvalleroy/following{/other_user}","gists_url":"https://api.github.com/users/jvalleroy/gists{/gist_id}","starred_url":"https://api.github.com/users/jvalleroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvalleroy/subscriptions","organizations_url":"https://api.github.com/users/jvalleroy/orgs","repos_url":"https://api.github.com/users/jvalleroy/repos","events_url":"https://api.github.com/users/jvalleroy/events{/privacy}","received_events_url":"https://api.github.com/users/jvalleroy/received_events","type":"User","site_admin":false},"body":"I get a KeyError here on the first run, probably because the language has not been set yet. It seems like we can just return None in case of the KeyError though.","created_at":"2015-11-21T21:25:32Z","updated_at":"2015-11-21T21:25:32Z","html_url":"https://github.com/freedombox/Plinth/pull/297#discussion_r45550937","pull_request_url":"https://api.github.com/repos/freedombox/Plinth/pulls/297","_links":{"self":{"href":"https://api.github.com/repos/freedombox/Plinth/pulls/comments/45550937"},"html":{"href":"https://github.com/freedombox/Plinth/pull/297#discussion_r45550937"},"pull_request":{"href":"https://api.github.com/repos/freedombox/Plinth/pulls/297"}}},"pull_request":{"url":"https://api.github.com/repos/freedombox/Plinth/pulls/297","id":51116363,"html_url":"https://github.com/freedombox/Plinth/pull/297","diff_url":"https://github.com/freedombox/Plinth/pull/297.diff","patch_url":"https://github.com/freedombox/Plinth/pull/297.patch","issue_url":"https://api.github.com/repos/freedombox/Plinth/issues/297","number":297,"state":"open","locked":false,"title":"Adds a 'language' dropdown field to the system configuration","user":{"login":"fonfon","id":1867309,"avatar_url":"https://avatars.githubusercontent.com/u/1867309?v=3","gravatar_id":"","url":"https://api.github.com/users/fonfon","html_url":"https://github.com/fonfon","followers_url":"https://api.github.com/users/fonfon/followers","following_url":"https://api.github.com/users/fonfon/following{/other_user}","gists_url":"https://api.github.com/users/fonfon/gists{/gist_id}","starred_url":"https://api.github.com/users/fonfon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fonfon/subscriptions","organizations_url":"https://api.github.com/users/fonfon/orgs","repos_url":"https://api.github.com/users/fonfon/repos","events_url":"https://api.github.com/users/fonfon/events{/privacy}","received_events_url":"https://api.github.com/users/fonfon/received_events","type":"User","site_admin":false},"body":"- The language choice is stored within the session, not persistently (in kvstore)\r\n- This removes confirmation messages if nothing was changed\r\n\r\nMaybe there is a better way to detect the plinth / locale directory than this:\r\nhttps://github.com/fonfon/Plinth/blob/language-detect/plinth/__main__.py#L218\r\n\r\nIf a user chooses a certain language his setting survives login/logout with the same browser, but won't survive using another browser or device. Thus we should use kvstore in the long run to store user language choices.","created_at":"2015-11-18T17:38:50Z","updated_at":"2015-11-21T21:25:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f495e224ad6e27831d107dc14b136b6cf525d140","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/freedombox/Plinth/pulls/297/commits","review_comments_url":"https://api.github.com/repos/freedombox/Plinth/pulls/297/comments","review_comment_url":"https://api.github.com/repos/freedombox/Plinth/pulls/comments{/number}","comments_url":"https://api.github.com/repos/freedombox/Plinth/issues/297/comments","statuses_url":"https://api.github.com/repos/freedombox/Plinth/statuses/aeaa6ab800a8f91579c9fa89ea3d6a86404829d3","head":{"label":"fonfon:language-detect","ref":"language-detect","sha":"aeaa6ab800a8f91579c9fa89ea3d6a86404829d3","user":{"login":"fonfon","id":1867309,"avatar_url":"https://avatars.githubusercontent.com/u/1867309?v=3","gravatar_id":"","url":"https://api.github.com/users/fonfon","html_url":"https://github.com/fonfon","followers_url":"https://api.github.com/users/fonfon/followers","following_url":"https://api.github.com/users/fonfon/following{/other_user}","gists_url":"https://api.github.com/users/fonfon/gists{/gist_id}","starred_url":"https://api.github.com/users/fonfon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fonfon/subscriptions","organizations_url":"https://api.github.com/users/fonfon/orgs","repos_url":"https://api.github.com/users/fonfon/repos","events_url":"https://api.github.com/users/fonfon/events{/privacy}","received_events_url":"https://api.github.com/users/fonfon/received_events","type":"User","site_admin":false},"repo":{"id":20817704,"name":"Plinth","full_name":"fonfon/Plinth","owner":{"login":"fonfon","id":1867309,"avatar_url":"https://avatars.githubusercontent.com/u/1867309?v=3","gravatar_id":"","url":"https://api.github.com/users/fonfon","html_url":"https://github.com/fonfon","followers_url":"https://api.github.com/users/fonfon/followers","following_url":"https://api.github.com/users/fonfon/following{/other_user}","gists_url":"https://api.github.com/users/fonfon/gists{/gist_id}","starred_url":"https://api.github.com/users/fonfon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fonfon/subscriptions","organizations_url":"https://api.github.com/users/fonfon/orgs","repos_url":"https://api.github.com/users/fonfon/repos","events_url":"https://api.github.com/users/fonfon/events{/privacy}","received_events_url":"https://api.github.com/users/fonfon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fonfon/Plinth","description":"Proposed Front End for Freedom Plug UI","fork":true,"url":"https://api.github.com/repos/fonfon/Plinth","forks_url":"https://api.github.com/repos/fonfon/Plinth/forks","keys_url":"https://api.github.com/repos/fonfon/Plinth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fonfon/Plinth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fonfon/Plinth/teams","hooks_url":"https://api.github.com/repos/fonfon/Plinth/hooks","issue_events_url":"https://api.github.com/repos/fonfon/Plinth/issues/events{/number}","events_url":"https://api.github.com/repos/fonfon/Plinth/events","assignees_url":"https://api.github.com/repos/fonfon/Plinth/assignees{/user}","branches_url":"https://api.github.com/repos/fonfon/Plinth/branches{/branch}","tags_url":"https://api.github.com/repos/fonfon/Plinth/tags","blobs_url":"https://api.github.com/repos/fonfon/Plinth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fonfon/Plinth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fonfon/Plinth/git/refs{/sha}","trees_url":"https://api.github.com/repos/fonfon/Plinth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fonfon/Plinth/statuses/{sha}","languages_url":"https://api.github.com/repos/fonfon/Plinth/languages","stargazers_url":"https://api.github.com/repos/fonfon/Plinth/stargazers","contributors_url":"https://api.github.com/repos/fonfon/Plinth/contributors","subscribers_url":"https://api.github.com/repos/fonfon/Plinth/subscribers","subscription_url":"https://api.github.com/repos/fonfon/Plinth/subscription","commits_url":"https://api.github.com/repos/fonfon/Plinth/commits{/sha}","git_commits_url":"https://api.github.com/repos/fonfon/Plinth/git/commits{/sha}","comments_url":"https://api.github.com/repos/fonfon/Plinth/comments{/number}","issue_comment_url":"https://api.github.com/repos/fonfon/Plinth/issues/comments{/number}","contents_url":"https://api.github.com/repos/fonfon/Plinth/contents/{+path}","compare_url":"https://api.github.com/repos/fonfon/Plinth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fonfon/Plinth/merges","archive_url":"https://api.github.com/repos/fonfon/Plinth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fonfon/Plinth/downloads","issues_url":"https://api.github.com/repos/fonfon/Plinth/issues{/number}","pulls_url":"https://api.github.com/repos/fonfon/Plinth/pulls{/number}","milestones_url":"https://api.github.com/repos/fonfon/Plinth/milestones{/number}","notifications_url":"https://api.github.com/repos/fonfon/Plinth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fonfon/Plinth/labels{/name}","releases_url":"https://api.github.com/repos/fonfon/Plinth/releases{/id}","created_at":"2014-06-13T21:02:34Z","updated_at":"2015-02-02T13:48:17Z","pushed_at":"2015-11-18T17:33:31Z","git_url":"git://github.com/fonfon/Plinth.git","ssh_url":"git@github.com:fonfon/Plinth.git","clone_url":"https://github.com/fonfon/Plinth.git","svn_url":"https://github.com/fonfon/Plinth","homepage":"","size":6387,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"freedombox:master","ref":"master","sha":"f8f7a979f2a43eec0d8790c24a534297f0438d1f","user":{"login":"freedombox","id":5255604,"avatar_url":"https://avatars.githubusercontent.com/u/5255604?v=3","gravatar_id":"","url":"https://api.github.com/users/freedombox","html_url":"https://github.com/freedombox","followers_url":"https://api.github.com/users/freedombox/followers","following_url":"https://api.github.com/users/freedombox/following{/other_user}","gists_url":"https://api.github.com/users/freedombox/gists{/gist_id}","starred_url":"https://api.github.com/users/freedombox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freedombox/subscriptions","organizations_url":"https://api.github.com/users/freedombox/orgs","repos_url":"https://api.github.com/users/freedombox/repos","events_url":"https://api.github.com/users/freedombox/events{/privacy}","received_events_url":"https://api.github.com/users/freedombox/received_events","type":"Organization","site_admin":false},"repo":{"id":12196957,"name":"Plinth","full_name":"freedombox/Plinth","owner":{"login":"freedombox","id":5255604,"avatar_url":"https://avatars.githubusercontent.com/u/5255604?v=3","gravatar_id":"","url":"https://api.github.com/users/freedombox","html_url":"https://github.com/freedombox","followers_url":"https://api.github.com/users/freedombox/followers","following_url":"https://api.github.com/users/freedombox/following{/other_user}","gists_url":"https://api.github.com/users/freedombox/gists{/gist_id}","starred_url":"https://api.github.com/users/freedombox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/freedombox/subscriptions","organizations_url":"https://api.github.com/users/freedombox/orgs","repos_url":"https://api.github.com/users/freedombox/repos","events_url":"https://api.github.com/users/freedombox/events{/privacy}","received_events_url":"https://api.github.com/users/freedombox/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/freedombox/Plinth","description":"Web UI for FreedomBox","fork":true,"url":"https://api.github.com/repos/freedombox/Plinth","forks_url":"https://api.github.com/repos/freedombox/Plinth/forks","keys_url":"https://api.github.com/repos/freedombox/Plinth/keys{/key_id}","collaborators_url":"https://api.github.com/repos/freedombox/Plinth/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/freedombox/Plinth/teams","hooks_url":"https://api.github.com/repos/freedombox/Plinth/hooks","issue_events_url":"https://api.github.com/repos/freedombox/Plinth/issues/events{/number}","events_url":"https://api.github.com/repos/freedombox/Plinth/events","assignees_url":"https://api.github.com/repos/freedombox/Plinth/assignees{/user}","branches_url":"https://api.github.com/repos/freedombox/Plinth/branches{/branch}","tags_url":"https://api.github.com/repos/freedombox/Plinth/tags","blobs_url":"https://api.github.com/repos/freedombox/Plinth/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/freedombox/Plinth/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/freedombox/Plinth/git/refs{/sha}","trees_url":"https://api.github.com/repos/freedombox/Plinth/git/trees{/sha}","statuses_url":"https://api.github.com/repos/freedombox/Plinth/statuses/{sha}","languages_url":"https://api.github.com/repos/freedombox/Plinth/languages","stargazers_url":"https://api.github.com/repos/freedombox/Plinth/stargazers","contributors_url":"https://api.github.com/repos/freedombox/Plinth/contributors","subscribers_url":"https://api.github.com/repos/freedombox/Plinth/subscribers","subscription_url":"https://api.github.com/repos/freedombox/Plinth/subscription","commits_url":"https://api.github.com/repos/freedombox/Plinth/commits{/sha}","git_commits_url":"https://api.github.com/repos/freedombox/Plinth/git/commits{/sha}","comments_url":"https://api.github.com/repos/freedombox/Plinth/comments{/number}","issue_comment_url":"https://api.github.com/repos/freedombox/Plinth/issues/comments{/number}","contents_url":"https://api.github.com/repos/freedombox/Plinth/contents/{+path}","compare_url":"https://api.github.com/repos/freedombox/Plinth/compare/{base}...{head}","merges_url":"https://api.github.com/repos/freedombox/Plinth/merges","archive_url":"https://api.github.com/repos/freedombox/Plinth/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/freedombox/Plinth/downloads","issues_url":"https://api.github.com/repos/freedombox/Plinth/issues{/number}","pulls_url":"https://api.github.com/repos/freedombox/Plinth/pulls{/number}","milestones_url":"https://api.github.com/repos/freedombox/Plinth/milestones{/number}","notifications_url":"https://api.github.com/repos/freedombox/Plinth/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/freedombox/Plinth/labels{/name}","releases_url":"https://api.github.com/repos/freedombox/Plinth/releases{/id}","created_at":"2013-08-18T15:10:42Z","updated_at":"2015-11-17T01:51:23Z","pushed_at":"2015-11-21T01:27:45Z","git_url":"git://github.com/freedombox/Plinth.git","ssh_url":"git@github.com:freedombox/Plinth.git","clone_url":"https://github.com/freedombox/Plinth.git","svn_url":"https://github.com/freedombox/Plinth","homepage":"https://freedomboxfoundation.org/","size":6455,"stargazers_count":26,"watchers_count":26,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"open_issues_count":95,"forks":24,"open_issues":95,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/freedombox/Plinth/pulls/297"},"html":{"href":"https://github.com/freedombox/Plinth/pull/297"},"issue":{"href":"https://api.github.com/repos/freedombox/Plinth/issues/297"},"comments":{"href":"https://api.github.com/repos/freedombox/Plinth/issues/297/comments"},"review_comments":{"href":"https://api.github.com/repos/freedombox/Plinth/pulls/297/comments"},"review_comment":{"href":"https://api.github.com/repos/freedombox/Plinth/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/freedombox/Plinth/pulls/297/commits"},"statuses":{"href":"https://api.github.com/repos/freedombox/Plinth/statuses/aeaa6ab800a8f91579c9fa89ea3d6a86404829d3"}}}}