Skip to content

Instantly share code, notes, and snippets.

View KevinVR's full-sized avatar
💻
Always Coding

Kevin Van Ryckegem KevinVR

💻
Always Coding
View GitHub Profile
// en.json
{
"website": {
"title": "My website"
}
}
// .jsx
const title = intl.formatMessage({ id: "website.title" });
function MyComponent({ intl }) {
// Here you can use intl
}
export default injectIntl(MyComponent);
import { injectIntl } from 'gatsby-plugin-intl';
// Using the function
const title = intl.formatMessage({ id: 'title' });
// Using the React component
import { FormattedMessage } from 'gatsby-plugin-intl';
<FormattedMessage id="title" />
const intl = useIntl();
import { useIntl } from 'gatsby-plugin-intl';
{
"title": "My test website",
"description": "My website description"
}
// 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