{"action":"created","comment":{"url":"https://api.github.com/repos/gocardless/splash-pages/pulls/comments/31053787","id":31053787,"diff_hunk":"@@ -0,0 +1,63 @@\n+import React from 'react';\n+import { PropTypes } from '../../helpers/prop-types/prop-types';\n+import isString from 'lodash/lang/isString';\n+import isPlainObject from 'lodash/lang/isPlainObject';\n+\n+function getMessageFromTranslations(name, messages) {\n+  return name.split('.').reduce(function(obj, pathPart) {\n+    return obj && obj[pathPart];\n+  }, messages);\n+}\n+\n+function isSubsetOfLocale(string, locale) {\n+  return locale.startsWith(string);\n+}\n+\n+function checkForDuplicateMessage(localeA, localeB, name, messages) {\n+  if (localeA !== localeB) { return; }\n+\n+  const messageExists = !!getMessageFromTranslations(name, messages);\n+\n+  if (messageExists) {\n+    throw new Error(`Duplicate translation found for ${name}`);\n+  }\n+}\n+\n+function getMessage({ currentLocale, givenLocale, givenContent, name, messages }) {\n+  checkForDuplicateMessage(currentLocale, givenLocale, name, messages);\n+\n+  const foundMessage = getMessageFromTranslations(name, messages);\n+\n+  if (foundMessage) {\n+    return foundMessage;\n+  }\n+\n+  if (isSubsetOfLocale(givenLocale, currentLocale)) {\n+    return givenContent;\n+  }\n+\n+  throw new ReferenceError(`Could not find Intl name: ${name}`);\n+}\n+\n+export default class InlineMessage extends React.Component {\n+  displayName = 'InlineMessage'\n+\n+  static propTypes = {\n+    children: PropTypes.node.isRequired,\n+    givenLocale: PropTypes.string.isRequired,\n+    name: PropTypes.string.isRequired,","path":"app/components/inline-message/inline-message.js","position":48,"original_position":48,"commit_id":"ebc0a68e1a7e3105791e83e3437cb6610a7f05d9","original_commit_id":"ebc0a68e1a7e3105791e83e3437cb6610a7f05d9","user":{"login":"harrison","id":20165,"avatar_url":"https://avatars.githubusercontent.com/u/20165?v=3","gravatar_id":"","url":"https://api.github.com/users/harrison","html_url":"https://github.com/harrison","followers_url":"https://api.github.com/users/harrison/followers","following_url":"https://api.github.com/users/harrison/following{/other_user}","gists_url":"https://api.github.com/users/harrison/gists{/gist_id}","starred_url":"https://api.github.com/users/harrison/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harrison/subscriptions","organizations_url":"https://api.github.com/users/harrison/orgs","repos_url":"https://api.github.com/users/harrison/repos","events_url":"https://api.github.com/users/harrison/events{/privacy}","received_events_url":"https://api.github.com/users/harrison/received_events","type":"User","site_admin":false},"body":"yeah would be nice to change `locales` to `currentLocale` :) thinking that `locale` is easier to remember here on the interface side","created_at":"2015-05-26T16:42:24Z","updated_at":"2015-05-26T16:42:24Z","html_url":"https://github.com/gocardless/splash-pages/pull/165#discussion_r31053787","pull_request_url":"https://api.github.com/repos/gocardless/splash-pages/pulls/165","_links":{"self":{"href":"https://api.github.com/repos/gocardless/splash-pages/pulls/comments/31053787"},"html":{"href":"https://github.com/gocardless/splash-pages/pull/165#discussion_r31053787"},"pull_request":{"href":"https://api.github.com/repos/gocardless/splash-pages/pulls/165"}}},"pull_request":{"url":"https://api.github.com/repos/gocardless/splash-pages/pulls/165","id":36064496,"html_url":"https://github.com/gocardless/splash-pages/pull/165","diff_url":"https://github.com/gocardless/splash-pages/pull/165.diff","patch_url":"https://github.com/gocardless/splash-pages/pull/165.patch","issue_url":"https://api.github.com/repos/gocardless/splash-pages/issues/165","number":165,"state":"open","locked":false,"title":"Proof of concept for inlining default message","user":{"login":"english","id":597448,"avatar_url":"https://avatars.githubusercontent.com/u/597448?v=3","gravatar_id":"","url":"https://api.github.com/users/english","html_url":"https://github.com/english","followers_url":"https://api.github.com/users/english/followers","following_url":"https://api.github.com/users/english/following{/other_user}","gists_url":"https://api.github.com/users/english/gists{/gist_id}","starred_url":"https://api.github.com/users/english/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/english/subscriptions","organizations_url":"https://api.github.com/users/english/orgs","repos_url":"https://api.github.com/users/english/repos","events_url":"https://api.github.com/users/english/events{/privacy}","received_events_url":"https://api.github.com/users/english/received_events","type":"User","site_admin":false},"body":"I don't want to merge this, its here only for discussion.\r\n\r\nThis explores writing `Message` components that are potentially translated into several languages with a 'default' language inline. This is different to what we had before as there would be no inline copy, all copy would live in a translation file.\r\n\r\nThe benefit of this is that you can see what the actual page looks like with copy in it as you are reading/writing a React page. Previously you would have to jump between the component and the translation file to get an idea of how the page would look.\r\n\r\n@harrison what do you think?","created_at":"2015-05-22T20:06:22Z","updated_at":"2015-05-26T16:42:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"229f904919ab322013f75bf7dd697becd39a3ec8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gocardless/splash-pages/pulls/165/commits","review_comments_url":"https://api.github.com/repos/gocardless/splash-pages/pulls/165/comments","review_comment_url":"https://api.github.com/repos/gocardless/splash-pages/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gocardless/splash-pages/issues/165/comments","statuses_url":"https://api.github.com/repos/gocardless/splash-pages/statuses/ebc0a68e1a7e3105791e83e3437cb6610a7f05d9","head":{"label":"gocardless:inline-message-spike","ref":"inline-message-spike","sha":"ebc0a68e1a7e3105791e83e3437cb6610a7f05d9","user":{"login":"gocardless","id":790629,"avatar_url":"https://avatars.githubusercontent.com/u/790629?v=3","gravatar_id":"","url":"https://api.github.com/users/gocardless","html_url":"https://github.com/gocardless","followers_url":"https://api.github.com/users/gocardless/followers","following_url":"https://api.github.com/users/gocardless/following{/other_user}","gists_url":"https://api.github.com/users/gocardless/gists{/gist_id}","starred_url":"https://api.github.com/users/gocardless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gocardless/subscriptions","organizations_url":"https://api.github.com/users/gocardless/orgs","repos_url":"https://api.github.com/users/gocardless/repos","events_url":"https://api.github.com/users/gocardless/events{/privacy}","received_events_url":"https://api.github.com/users/gocardless/received_events","type":"Organization","site_admin":false},"repo":{"id":33721890,"name":"splash-pages","full_name":"gocardless/splash-pages","owner":{"login":"gocardless","id":790629,"avatar_url":"https://avatars.githubusercontent.com/u/790629?v=3","gravatar_id":"","url":"https://api.github.com/users/gocardless","html_url":"https://github.com/gocardless","followers_url":"https://api.github.com/users/gocardless/followers","following_url":"https://api.github.com/users/gocardless/following{/other_user}","gists_url":"https://api.github.com/users/gocardless/gists{/gist_id}","starred_url":"https://api.github.com/users/gocardless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gocardless/subscriptions","organizations_url":"https://api.github.com/users/gocardless/orgs","repos_url":"https://api.github.com/users/gocardless/repos","events_url":"https://api.github.com/users/gocardless/events{/privacy}","received_events_url":"https://api.github.com/users/gocardless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gocardless/splash-pages","description":"Splash Pages for https://gocardless.com","fork":false,"url":"https://api.github.com/repos/gocardless/splash-pages","forks_url":"https://api.github.com/repos/gocardless/splash-pages/forks","keys_url":"https://api.github.com/repos/gocardless/splash-pages/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gocardless/splash-pages/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gocardless/splash-pages/teams","hooks_url":"https://api.github.com/repos/gocardless/splash-pages/hooks","issue_events_url":"https://api.github.com/repos/gocardless/splash-pages/issues/events{/number}","events_url":"https://api.github.com/repos/gocardless/splash-pages/events","assignees_url":"https://api.github.com/repos/gocardless/splash-pages/assignees{/user}","branches_url":"https://api.github.com/repos/gocardless/splash-pages/branches{/branch}","tags_url":"https://api.github.com/repos/gocardless/splash-pages/tags","blobs_url":"https://api.github.com/repos/gocardless/splash-pages/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gocardless/splash-pages/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gocardless/splash-pages/git/refs{/sha}","trees_url":"https://api.github.com/repos/gocardless/splash-pages/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gocardless/splash-pages/statuses/{sha}","languages_url":"https://api.github.com/repos/gocardless/splash-pages/languages","stargazers_url":"https://api.github.com/repos/gocardless/splash-pages/stargazers","contributors_url":"https://api.github.com/repos/gocardless/splash-pages/contributors","subscribers_url":"https://api.github.com/repos/gocardless/splash-pages/subscribers","subscription_url":"https://api.github.com/repos/gocardless/splash-pages/subscription","commits_url":"https://api.github.com/repos/gocardless/splash-pages/commits{/sha}","git_commits_url":"https://api.github.com/repos/gocardless/splash-pages/git/commits{/sha}","comments_url":"https://api.github.com/repos/gocardless/splash-pages/comments{/number}","issue_comment_url":"https://api.github.com/repos/gocardless/splash-pages/issues/comments{/number}","contents_url":"https://api.github.com/repos/gocardless/splash-pages/contents/{+path}","compare_url":"https://api.github.com/repos/gocardless/splash-pages/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gocardless/splash-pages/merges","archive_url":"https://api.github.com/repos/gocardless/splash-pages/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gocardless/splash-pages/downloads","issues_url":"https://api.github.com/repos/gocardless/splash-pages/issues{/number}","pulls_url":"https://api.github.com/repos/gocardless/splash-pages/pulls{/number}","milestones_url":"https://api.github.com/repos/gocardless/splash-pages/milestones{/number}","notifications_url":"https://api.github.com/repos/gocardless/splash-pages/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gocardless/splash-pages/labels{/name}","releases_url":"https://api.github.com/repos/gocardless/splash-pages/releases{/id}","created_at":"2015-04-10T10:02:43Z","updated_at":"2015-05-25T12:53:54Z","pushed_at":"2015-05-26T16:34:49Z","git_url":"git://github.com/gocardless/splash-pages.git","ssh_url":"git@github.com:gocardless/splash-pages.git","clone_url":"https://github.com/gocardless/splash-pages.git","svn_url":"https://github.com/gocardless/splash-pages","homepage":"","size":16385,"stargazers_count":29,"watchers_count":29,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":29,"default_branch":"dev"}},"base":{"label":"gocardless:dev","ref":"dev","sha":"32b76d50f1df21108bd7b132c73b2f3ec45cb211","user":{"login":"gocardless","id":790629,"avatar_url":"https://avatars.githubusercontent.com/u/790629?v=3","gravatar_id":"","url":"https://api.github.com/users/gocardless","html_url":"https://github.com/gocardless","followers_url":"https://api.github.com/users/gocardless/followers","following_url":"https://api.github.com/users/gocardless/following{/other_user}","gists_url":"https://api.github.com/users/gocardless/gists{/gist_id}","starred_url":"https://api.github.com/users/gocardless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gocardless/subscriptions","organizations_url":"https://api.github.com/users/gocardless/orgs","repos_url":"https://api.github.com/users/gocardless/repos","events_url":"https://api.github.com/users/gocardless/events{/privacy}","received_events_url":"https://api.github.com/users/gocardless/received_events","type":"Organization","site_admin":false},"repo":{"id":33721890,"name":"splash-pages","full_name":"gocardless/splash-pages","owner":{"login":"gocardless","id":790629,"avatar_url":"https://avatars.githubusercontent.com/u/790629?v=3","gravatar_id":"","url":"https://api.github.com/users/gocardless","html_url":"https://github.com/gocardless","followers_url":"https://api.github.com/users/gocardless/followers","following_url":"https://api.github.com/users/gocardless/following{/other_user}","gists_url":"https://api.github.com/users/gocardless/gists{/gist_id}","starred_url":"https://api.github.com/users/gocardless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gocardless/subscriptions","organizations_url":"https://api.github.com/users/gocardless/orgs","repos_url":"https://api.github.com/users/gocardless/repos","events_url":"https://api.github.com/users/gocardless/events{/privacy}","received_events_url":"https://api.github.com/users/gocardless/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gocardless/splash-pages","description":"Splash Pages for https://gocardless.com","fork":false,"url":"https://api.github.com/repos/gocardless/splash-pages","forks_url":"https://api.github.com/repos/gocardless/splash-pages/forks","keys_url":"https://api.github.com/repos/gocardless/splash-pages/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gocardless/splash-pages/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gocardless/splash-pages/teams","hooks_url":"https://api.github.com/repos/gocardless/splash-pages/hooks","issue_events_url":"https://api.github.com/repos/gocardless/splash-pages/issues/events{/number}","events_url":"https://api.github.com/repos/gocardless/splash-pages/events","assignees_url":"https://api.github.com/repos/gocardless/splash-pages/assignees{/user}","branches_url":"https://api.github.com/repos/gocardless/splash-pages/branches{/branch}","tags_url":"https://api.github.com/repos/gocardless/splash-pages/tags","blobs_url":"https://api.github.com/repos/gocardless/splash-pages/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gocardless/splash-pages/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gocardless/splash-pages/git/refs{/sha}","trees_url":"https://api.github.com/repos/gocardless/splash-pages/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gocardless/splash-pages/statuses/{sha}","languages_url":"https://api.github.com/repos/gocardless/splash-pages/languages","stargazers_url":"https://api.github.com/repos/gocardless/splash-pages/stargazers","contributors_url":"https://api.github.com/repos/gocardless/splash-pages/contributors","subscribers_url":"https://api.github.com/repos/gocardless/splash-pages/subscribers","subscription_url":"https://api.github.com/repos/gocardless/splash-pages/subscription","commits_url":"https://api.github.com/repos/gocardless/splash-pages/commits{/sha}","git_commits_url":"https://api.github.com/repos/gocardless/splash-pages/git/commits{/sha}","comments_url":"https://api.github.com/repos/gocardless/splash-pages/comments{/number}","issue_comment_url":"https://api.github.com/repos/gocardless/splash-pages/issues/comments{/number}","contents_url":"https://api.github.com/repos/gocardless/splash-pages/contents/{+path}","compare_url":"https://api.github.com/repos/gocardless/splash-pages/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gocardless/splash-pages/merges","archive_url":"https://api.github.com/repos/gocardless/splash-pages/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gocardless/splash-pages/downloads","issues_url":"https://api.github.com/repos/gocardless/splash-pages/issues{/number}","pulls_url":"https://api.github.com/repos/gocardless/splash-pages/pulls{/number}","milestones_url":"https://api.github.com/repos/gocardless/splash-pages/milestones{/number}","notifications_url":"https://api.github.com/repos/gocardless/splash-pages/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gocardless/splash-pages/labels{/name}","releases_url":"https://api.github.com/repos/gocardless/splash-pages/releases{/id}","created_at":"2015-04-10T10:02:43Z","updated_at":"2015-05-25T12:53:54Z","pushed_at":"2015-05-26T16:34:49Z","git_url":"git://github.com/gocardless/splash-pages.git","ssh_url":"git@github.com:gocardless/splash-pages.git","clone_url":"https://github.com/gocardless/splash-pages.git","svn_url":"https://github.com/gocardless/splash-pages","homepage":"","size":16385,"stargazers_count":29,"watchers_count":29,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":8,"forks":1,"open_issues":8,"watchers":29,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/gocardless/splash-pages/pulls/165"},"html":{"href":"https://github.com/gocardless/splash-pages/pull/165"},"issue":{"href":"https://api.github.com/repos/gocardless/splash-pages/issues/165"},"comments":{"href":"https://api.github.com/repos/gocardless/splash-pages/issues/165/comments"},"review_comments":{"href":"https://api.github.com/repos/gocardless/splash-pages/pulls/165/comments"},"review_comment":{"href":"https://api.github.com/repos/gocardless/splash-pages/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gocardless/splash-pages/pulls/165/commits"},"statuses":{"href":"https://api.github.com/repos/gocardless/splash-pages/statuses/ebc0a68e1a7e3105791e83e3437cb6610a7f05d9"}}}}