Open Tbaut opened 4 years ago
Could you try with the following .babelrc
?
{
"presets": [["babel-preset-gatsby"]],
"plugins": [
[
"react-intl",
{
"moduleSourceName": "gatsby-plugin-intl"
}
],
[
"react-intl-auto",
{
"moduleSourceName": "gatsby-plugin-intl"
}
]
]
}
With this, it works on my side. I think there's probably a bug somewhere that made the need for such a configuration, but I've been struggling to figure out what's going on.
Thanks for you reply, For the record, this was my babel.config.js
:
module.exports = function (api) {
api.cache(true);
return {
presets: ["@babel/preset-react", "@babel/preset-typescript", "babel-preset-gatsby"]
}
};
Unfortunately following your suggestion, adding the plugins in babel config (also I had to install babel-plugin-react-intl-auto
), this did not solve the problem.
Just to narrow down the problem a little, in my example from the first post, whether I use intl.formatMessage
or the JSX component FormattedMessage
doesn't matter, both:
import { useIntl, defineMessages } from "gatsby-plugin-intl";
const intl = useIntl();
const messages = defineMessages({
description: {
id: "about.description",
defaultMessage: "this description isn't picked up",
values: {
newline: <br />,
},
},
});
...
{intl.formatMessage(messages.description)}
and
import { FormattedMessage, defineMessages } from "gatsby-plugin-intl";
const messages = defineMessages({
description: {
id: "about.description",
defaultMessage: "this description isn't picked up",
values: {
newline: <br />,
},
},
});
...
<FormattedMessage {...messages.description} />
yield the same result: no description
field is created in translation's JSONs.
Thanks for this great plugin! I run into problems with gatsby and TS, any help or pointer would be greatly appreciated.
node
version: 12.4npm
(oryarn
) version: yarn 1.22.4Do you want to request a feature or report a bug?: bug
What is the current behavior?: I import
defineMessages
fromgatsby-plugin-intl
, not fromreact-intl
.When running
on a page containing:
it detects and generates only the title, not the description message:
What is the expected behavior?: I would expect: