{"action":"created","issue":{"url":"https://api.github.com/repos/yahoo/react-intl/issues/343","repository_url":"https://api.github.com/repos/yahoo/react-intl","labels_url":"https://api.github.com/repos/yahoo/react-intl/issues/343/labels{/name}","comments_url":"https://api.github.com/repos/yahoo/react-intl/issues/343/comments","events_url":"https://api.github.com/repos/yahoo/react-intl/issues/343/events","html_url":"https://github.com/yahoo/react-intl/issues/343","id":137883437,"number":343,"title":"Access to defineMessages by string  - not only by key","user":{"login":"Shachar16290","id":13366189,"avatar_url":"https://avatars.githubusercontent.com/u/13366189?v=3","gravatar_id":"","url":"https://api.github.com/users/Shachar16290","html_url":"https://github.com/Shachar16290","followers_url":"https://api.github.com/users/Shachar16290/followers","following_url":"https://api.github.com/users/Shachar16290/following{/other_user}","gists_url":"https://api.github.com/users/Shachar16290/gists{/gist_id}","starred_url":"https://api.github.com/users/Shachar16290/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shachar16290/subscriptions","organizations_url":"https://api.github.com/users/Shachar16290/orgs","repos_url":"https://api.github.com/users/Shachar16290/repos","events_url":"https://api.github.com/users/Shachar16290/events{/privacy}","received_events_url":"https://api.github.com/users/Shachar16290/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yahoo/react-intl/labels/needs%20info","name":"needs info","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-02T14:12:30Z","updated_at":"2016-03-03T12:25:09Z","closed_at":null,"body":"Hi,\r\n\r\nI'm using react-intl and I wish to have the option to write defineMessages this way: \r\n\r\n```javascript\r\nconst messages = defineMessages({\r\n \"my.namespaced.id\": { \r\n      defaultMessage: \"My message\", \r\n      description: \"My description\" \r\n  }\r\n}\r\n```\r\n\r\nAnd then do : \r\n\r\n```javascript\r\n {...messages[\"my.namespace.id\"]}\r\n```\r\n\r\nI notice other people asked for it in here:  #162 \r\n\r\nFor now, I use only external messages file and pass it to IntlProvider and then access the messages by string id with InjectIntl -  formatMessage.\r\nI want the option to use defineMessages inside each component and not in external file.\r\n\r\nThank you."},"comment":{"url":"https://api.github.com/repos/yahoo/react-intl/issues/comments/191735066","html_url":"https://github.com/yahoo/react-intl/issues/343#issuecomment-191735066","issue_url":"https://api.github.com/repos/yahoo/react-intl/issues/343","id":191735066,"user":{"login":"Shachar16290","id":13366189,"avatar_url":"https://avatars.githubusercontent.com/u/13366189?v=3","gravatar_id":"","url":"https://api.github.com/users/Shachar16290","html_url":"https://github.com/Shachar16290","followers_url":"https://api.github.com/users/Shachar16290/followers","following_url":"https://api.github.com/users/Shachar16290/following{/other_user}","gists_url":"https://api.github.com/users/Shachar16290/gists{/gist_id}","starred_url":"https://api.github.com/users/Shachar16290/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Shachar16290/subscriptions","organizations_url":"https://api.github.com/users/Shachar16290/orgs","repos_url":"https://api.github.com/users/Shachar16290/repos","events_url":"https://api.github.com/users/Shachar16290/events{/privacy}","received_events_url":"https://api.github.com/users/Shachar16290/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T12:25:09Z","updated_at":"2016-03-03T12:25:09Z","body":"> I don't understand what you're asking for which isn't already possible today.\r\n\r\nI think you did not understand me.\r\nI would like to access my messages by string and not by key. I'm trying to map types generically. For example: \r\nOne of my component props is type('sms', 'call' etc..) - `this.props.type` . I want to map it to message from `messages`:\r\n\r\n```javascript\r\nconst messages = defineMessages({\r\n \"sms\": { \r\n      defaultMessage: \"My SMS message\", \r\n      description: \"My description\" \r\n  },\r\n \"call\": { \r\n      defaultMessage: \"My CALL message\", \r\n      description: \"My description\" \r\n  }\r\n}\r\n```\r\nand then to access it in my component :\r\n\r\n```javascript\r\n {...messages[this.props.type]}\r\n```\r\nThis way I wont need to check which message I need to present. \r\nHope it is more informative now."}}