{"action":"created","comment":{"url":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments/72459550","id":72459550,"diff_hunk":"@@ -0,0 +1,125 @@\n+goog.provide('app.Lang');\n+\n+goog.require('app');\n+goog.require('ngeo.GetBrowserLanguage');\n+\n+\n+/**\n+ * @param {angular.$cookies} $cookies Cookies service.\n+ * @param {angularGettext.Catalog} gettextCatalog Gettext catalog.\n+ * @param {ngeo.GetBrowserLanguage} ngeoGetBrowserLanguage\n+ *        GetBrowserLanguage Service.\n+ * @param {Array.<string>} langs List of available langs.\n+ * @param {amMoment} amMoment angular moment directive.\n+ * @param {app.Api} appApi Api service.\n+ * @param {app.Authentication} appAuthentication Authentication service.\n+ * @param {string} langUrlTemplate Language URL template.\n+ * @constructor\n+ * @ngInject\n+ * @struct\n+ */\n+app.Lang = function($cookies, gettextCatalog, ngeoGetBrowserLanguage, langs,\n+  amMoment, appApi, appAuthentication, langUrlTemplate) {\n+\n+  /**\n+   * @type {angular.$cookies}\n+   * @private\n+   */\n+  this.cookies_ = $cookies;\n+\n+  /**\n+   * @type {angularGettext.Catalog}\n+   * @private\n+   */\n+  this.gettextCatalog_ = gettextCatalog;\n+\n+  /**\n+   * @type {ngeo.GetBrowserLanguage}\n+   * @private\n+   */\n+  this.ngeoGetBrowserLanguage_ = ngeoGetBrowserLanguage;\n+\n+  /**\n+   * @type {Array.<string>}\n+   * @private\n+   */\n+  this.langs_ = langs;\n+\n+  /**\n+   * @type {amMoment}\n+   */\n+  this.amMoment_ = amMoment;\n+\n+  /**\n+   * @type {app.Api}\n+   * @private\n+   */\n+  this.api_ = appApi;\n+\n+  /**\n+   * @type {app.Authentication}\n+   * @private\n+   */\n+  this.appAuthentication_ = appAuthentication;\n+\n+  /**\n+   * @type {string}\n+   * @private\n+   */\n+  this.langUrlTemplate_ = langUrlTemplate;\n+\n+  this.updateLang(\n+    this.cookies_.get('interface_lang') ||\n+    this.ngeoGetBrowserLanguage_(this.langs_) || 'fr'\n+  );\n+};\n+\n+\n+/**\n+ * @return {Array.<string>}\n+ */\n+app.Lang.prototype.getAvailableLangs = function() {\n+  return this.langs_;\n+};\n+\n+\n+/**\n+ * @return {string}\n+ */\n+app.Lang.prototype.getLang = function() {\n+  return this.gettextCatalog_.currentLanguage;\n+};\n+\n+\n+/**\n+ * @param {string} lang\n+ */\n+app.Lang.prototype.updateLang = function(lang) {\n+  this.gettextCatalog_.setCurrentLanguage(lang);\n+  this.gettextCatalog_.loadRemote(\n+          this.langUrlTemplate_.replace('__lang__', lang));\n+  // store the interface language as cookie, so that it is available on the\n+  // server side.\n+  var d = new Date();\n+  d.setFullYear(d.getFullYear() + 1); // today + 1 year\n+  this.cookies_.put('interface_lang', lang, {\n+    'path': '/',\n+    'expires': d\n+  });\n+\n+  if (this.appAuthentication_.isAuthenticated()) {\n+    this.api_.updatePreferredLanguage(lang);","path":"c2corg_ui/static/js/langservice.js","position":111,"original_position":111,"commit_id":"030ff9adec1741bd994fdde4d8d7b826d378bf69","original_commit_id":"030ff9adec1741bd994fdde4d8d7b826d378bf69","user":{"login":"tsauerwein","id":266474,"avatar_url":"https://avatars.githubusercontent.com/u/266474?v=3","gravatar_id":"","url":"https://api.github.com/users/tsauerwein","html_url":"https://github.com/tsauerwein","followers_url":"https://api.github.com/users/tsauerwein/followers","following_url":"https://api.github.com/users/tsauerwein/following{/other_user}","gists_url":"https://api.github.com/users/tsauerwein/gists{/gist_id}","starred_url":"https://api.github.com/users/tsauerwein/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tsauerwein/subscriptions","organizations_url":"https://api.github.com/users/tsauerwein/orgs","repos_url":"https://api.github.com/users/tsauerwein/repos","events_url":"https://api.github.com/users/tsauerwein/events{/privacy}","received_events_url":"https://api.github.com/users/tsauerwein/received_events","type":"User","site_admin":false},"body":"At which point do we load the preferred language from the server?","created_at":"2016-07-27T15:16:55Z","updated_at":"2016-07-27T15:16:55Z","html_url":"https://github.com/c2corg/v6_ui/pull/537#discussion_r72459550","pull_request_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/537","_links":{"self":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments/72459550"},"html":{"href":"https://github.com/c2corg/v6_ui/pull/537#discussion_r72459550"},"pull_request":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/537"}}},"pull_request":{"url":"https://api.github.com/repos/c2corg/v6_ui/pulls/537","id":79022674,"html_url":"https://github.com/c2corg/v6_ui/pull/537","diff_url":"https://github.com/c2corg/v6_ui/pull/537.diff","patch_url":"https://github.com/c2corg/v6_ui/pull/537.patch","issue_url":"https://api.github.com/repos/c2corg/v6_ui/issues/537","number":537,"state":"open","locked":false,"title":"Add a lang service","user":{"login":"asaunier","id":1192331,"avatar_url":"https://avatars.githubusercontent.com/u/1192331?v=3","gravatar_id":"","url":"https://api.github.com/users/asaunier","html_url":"https://github.com/asaunier","followers_url":"https://api.github.com/users/asaunier/followers","following_url":"https://api.github.com/users/asaunier/following{/other_user}","gists_url":"https://api.github.com/users/asaunier/gists{/gist_id}","starred_url":"https://api.github.com/users/asaunier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asaunier/subscriptions","organizations_url":"https://api.github.com/users/asaunier/orgs","repos_url":"https://api.github.com/users/asaunier/repos","events_url":"https://api.github.com/users/asaunier/events{/privacy}","received_events_url":"https://api.github.com/users/asaunier/received_events","type":"User","site_admin":false},"body":"as suggested by @tsauerwein at https://github.com/c2corg/v6_ui/pull/525#issuecomment-235191318","created_at":"2016-07-27T13:22:07Z","updated_at":"2016-07-27T15:16:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5fd5cf7b8d2ac9763f36e98e5b6ebd9c3b1186b3","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/537/commits","review_comments_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/537/comments","review_comment_url":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments{/number}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/issues/537/comments","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/030ff9adec1741bd994fdde4d8d7b826d378bf69","head":{"label":"c2corg:lang-service","ref":"lang-service","sha":"030ff9adec1741bd994fdde4d8d7b826d378bf69","user":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"repo":{"id":43445823,"name":"v6_ui","full_name":"c2corg/v6_ui","owner":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c2corg/v6_ui","description":"UI for c2c.org v6","fork":false,"url":"https://api.github.com/repos/c2corg/v6_ui","forks_url":"https://api.github.com/repos/c2corg/v6_ui/forks","keys_url":"https://api.github.com/repos/c2corg/v6_ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c2corg/v6_ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c2corg/v6_ui/teams","hooks_url":"https://api.github.com/repos/c2corg/v6_ui/hooks","issue_events_url":"https://api.github.com/repos/c2corg/v6_ui/issues/events{/number}","events_url":"https://api.github.com/repos/c2corg/v6_ui/events","assignees_url":"https://api.github.com/repos/c2corg/v6_ui/assignees{/user}","branches_url":"https://api.github.com/repos/c2corg/v6_ui/branches{/branch}","tags_url":"https://api.github.com/repos/c2corg/v6_ui/tags","blobs_url":"https://api.github.com/repos/c2corg/v6_ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c2corg/v6_ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c2corg/v6_ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/c2corg/v6_ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/{sha}","languages_url":"https://api.github.com/repos/c2corg/v6_ui/languages","stargazers_url":"https://api.github.com/repos/c2corg/v6_ui/stargazers","contributors_url":"https://api.github.com/repos/c2corg/v6_ui/contributors","subscribers_url":"https://api.github.com/repos/c2corg/v6_ui/subscribers","subscription_url":"https://api.github.com/repos/c2corg/v6_ui/subscription","commits_url":"https://api.github.com/repos/c2corg/v6_ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/c2corg/v6_ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/c2corg/v6_ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/c2corg/v6_ui/contents/{+path}","compare_url":"https://api.github.com/repos/c2corg/v6_ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c2corg/v6_ui/merges","archive_url":"https://api.github.com/repos/c2corg/v6_ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c2corg/v6_ui/downloads","issues_url":"https://api.github.com/repos/c2corg/v6_ui/issues{/number}","pulls_url":"https://api.github.com/repos/c2corg/v6_ui/pulls{/number}","milestones_url":"https://api.github.com/repos/c2corg/v6_ui/milestones{/number}","notifications_url":"https://api.github.com/repos/c2corg/v6_ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c2corg/v6_ui/labels{/name}","releases_url":"https://api.github.com/repos/c2corg/v6_ui/releases{/id}","deployments_url":"https://api.github.com/repos/c2corg/v6_ui/deployments","created_at":"2015-09-30T16:52:44Z","updated_at":"2016-04-12T09:20:57Z","pushed_at":"2016-07-27T15:08:52Z","git_url":"git://github.com/c2corg/v6_ui.git","ssh_url":"git@github.com:c2corg/v6_ui.git","clone_url":"https://github.com/c2corg/v6_ui.git","svn_url":"https://github.com/c2corg/v6_ui","homepage":null,"size":2297,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":104,"forks":2,"open_issues":104,"watchers":2,"default_branch":"master"}},"base":{"label":"c2corg:master","ref":"master","sha":"beb642ed92a296d59b83135658429f96ed8c1f50","user":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"repo":{"id":43445823,"name":"v6_ui","full_name":"c2corg/v6_ui","owner":{"login":"c2corg","id":3200587,"avatar_url":"https://avatars.githubusercontent.com/u/3200587?v=3","gravatar_id":"","url":"https://api.github.com/users/c2corg","html_url":"https://github.com/c2corg","followers_url":"https://api.github.com/users/c2corg/followers","following_url":"https://api.github.com/users/c2corg/following{/other_user}","gists_url":"https://api.github.com/users/c2corg/gists{/gist_id}","starred_url":"https://api.github.com/users/c2corg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c2corg/subscriptions","organizations_url":"https://api.github.com/users/c2corg/orgs","repos_url":"https://api.github.com/users/c2corg/repos","events_url":"https://api.github.com/users/c2corg/events{/privacy}","received_events_url":"https://api.github.com/users/c2corg/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/c2corg/v6_ui","description":"UI for c2c.org v6","fork":false,"url":"https://api.github.com/repos/c2corg/v6_ui","forks_url":"https://api.github.com/repos/c2corg/v6_ui/forks","keys_url":"https://api.github.com/repos/c2corg/v6_ui/keys{/key_id}","collaborators_url":"https://api.github.com/repos/c2corg/v6_ui/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/c2corg/v6_ui/teams","hooks_url":"https://api.github.com/repos/c2corg/v6_ui/hooks","issue_events_url":"https://api.github.com/repos/c2corg/v6_ui/issues/events{/number}","events_url":"https://api.github.com/repos/c2corg/v6_ui/events","assignees_url":"https://api.github.com/repos/c2corg/v6_ui/assignees{/user}","branches_url":"https://api.github.com/repos/c2corg/v6_ui/branches{/branch}","tags_url":"https://api.github.com/repos/c2corg/v6_ui/tags","blobs_url":"https://api.github.com/repos/c2corg/v6_ui/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/c2corg/v6_ui/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/c2corg/v6_ui/git/refs{/sha}","trees_url":"https://api.github.com/repos/c2corg/v6_ui/git/trees{/sha}","statuses_url":"https://api.github.com/repos/c2corg/v6_ui/statuses/{sha}","languages_url":"https://api.github.com/repos/c2corg/v6_ui/languages","stargazers_url":"https://api.github.com/repos/c2corg/v6_ui/stargazers","contributors_url":"https://api.github.com/repos/c2corg/v6_ui/contributors","subscribers_url":"https://api.github.com/repos/c2corg/v6_ui/subscribers","subscription_url":"https://api.github.com/repos/c2corg/v6_ui/subscription","commits_url":"https://api.github.com/repos/c2corg/v6_ui/commits{/sha}","git_commits_url":"https://api.github.com/repos/c2corg/v6_ui/git/commits{/sha}","comments_url":"https://api.github.com/repos/c2corg/v6_ui/comments{/number}","issue_comment_url":"https://api.github.com/repos/c2corg/v6_ui/issues/comments{/number}","contents_url":"https://api.github.com/repos/c2corg/v6_ui/contents/{+path}","compare_url":"https://api.github.com/repos/c2corg/v6_ui/compare/{base}...{head}","merges_url":"https://api.github.com/repos/c2corg/v6_ui/merges","archive_url":"https://api.github.com/repos/c2corg/v6_ui/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/c2corg/v6_ui/downloads","issues_url":"https://api.github.com/repos/c2corg/v6_ui/issues{/number}","pulls_url":"https://api.github.com/repos/c2corg/v6_ui/pulls{/number}","milestones_url":"https://api.github.com/repos/c2corg/v6_ui/milestones{/number}","notifications_url":"https://api.github.com/repos/c2corg/v6_ui/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/c2corg/v6_ui/labels{/name}","releases_url":"https://api.github.com/repos/c2corg/v6_ui/releases{/id}","deployments_url":"https://api.github.com/repos/c2corg/v6_ui/deployments","created_at":"2015-09-30T16:52:44Z","updated_at":"2016-04-12T09:20:57Z","pushed_at":"2016-07-27T15:08:52Z","git_url":"git://github.com/c2corg/v6_ui.git","ssh_url":"git@github.com:c2corg/v6_ui.git","clone_url":"https://github.com/c2corg/v6_ui.git","svn_url":"https://github.com/c2corg/v6_ui","homepage":null,"size":2297,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":104,"forks":2,"open_issues":104,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/537"},"html":{"href":"https://github.com/c2corg/v6_ui/pull/537"},"issue":{"href":"https://api.github.com/repos/c2corg/v6_ui/issues/537"},"comments":{"href":"https://api.github.com/repos/c2corg/v6_ui/issues/537/comments"},"review_comments":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/537/comments"},"review_comment":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/c2corg/v6_ui/pulls/537/commits"},"statuses":{"href":"https://api.github.com/repos/c2corg/v6_ui/statuses/030ff9adec1741bd994fdde4d8d7b826d378bf69"}}}}
{"actor":{"display_login":"tsauerwein"}}