Last active
April 21, 2016 19:36
-
-
Save l0gicgate/0f8c03e1b75fda2a3eb60743f008472a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"menu.item": "Menu Item", | |
"menu.item1": "Menu Item 1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { defineMessages } from 'react-intl'; | |
import FormattedAnchor from './FormattedAnchor'; | |
const messages = defineMessages({ | |
menuItem: { | |
id: 'menu.item', | |
defaultMessage: 'Menu Item', | |
}, | |
menuItem1: { | |
id: 'menu.item1', | |
defaultMessage: 'Menu Item 1', | |
}, | |
}); | |
class ExampleComponent extends React.Component { | |
render() { | |
return ( | |
<div> | |
<FormattedAnchor msg={messages.menuItem} /> | |
<FormattedAnchor href="some_page.html" msg={messages.menuItem1} target="_blank" /> | |
</div> | |
); | |
} | |
} | |
export default ExampleComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { injectIntl } from 'react-intl'; | |
const FormattedAnchor = (props) => { | |
const { formattedMessage } = this.props.intl; | |
return ( | |
<a | |
title={formattedMessage(props.msg)} | |
{...props} | |
/> | |
); | |
}; | |
export default injectIntl(FormattedAnchor); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"menu.item": "Item du Menu", | |
"menu.item1": "Item du Menu 1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { PropTypes } from 'react'; | |
import ExampleComponent from './ExampleComponent'; | |
import { addLocaleData, IntlProvider } from 'react-intl'; | |
import enMessages from './en.json'; | |
import enLocaleData from 'react-intl/locale-data/en'; | |
addLocaleData(enLocaleData); | |
import frMessages from './fr.json'; | |
import frLocaleData from 'react-intl/locale-data/fr'; | |
addLocaleData(frLocaleData); | |
export class App extends React.Component { | |
render() { | |
return ( | |
<IntlProvider locale="en" messages={enMessages}> | |
<ExampleComponent /> | |
</IntlProvider> | |
); | |
} | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment