This file contains hidden or 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
| // en.json | |
| { | |
| "website": { | |
| "title": "My website" | |
| } | |
| } | |
| // .jsx | |
| const title = intl.formatMessage({ id: "website.title" }); |
This file contains hidden or 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
| <Link to="/contact"> | |
| {intl.formatMessage({ id: "go_to_contact" })} | |
| </Link> |
This file contains hidden or 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
| function MyComponent({ intl }) { | |
| // Here you can use intl | |
| } |
This file contains hidden or 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
| export default injectIntl(MyComponent); |
This file contains hidden or 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 { injectIntl } from 'gatsby-plugin-intl'; |
This file contains hidden or 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
| // Using the function | |
| const title = intl.formatMessage({ id: 'title' }); | |
| // Using the React component | |
| import { FormattedMessage } from 'gatsby-plugin-intl'; | |
| <FormattedMessage id="title" /> |
This file contains hidden or 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
| const intl = useIntl(); |
This file contains hidden or 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 { useIntl } from 'gatsby-plugin-intl'; |
This file contains hidden or 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
| { | |
| "title": "My test website", | |
| "description": "My website description" | |
| } |
This file contains hidden or 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
| // from https://www.npmjs.com/package/gatsby-plugin-intl | |
| plugins: [ | |
| { | |
| resolve: `gatsby-plugin-intl`, | |
| options: { | |
| // language JSON resource path | |
| path: `${__dirname}/src/intl`, | |
| // supported language | |
| languages: [`en`, `ko`, `de`], | |
| // language file path |