Skip to content

Json key not generated for fields defined by defineMessages from gatsby-plugin-intl #78

@Tbaut

Description

@Tbaut

Thanks for this great plugin! I run into problems with gatsby and TS, any help or pointer would be greatly appreciated.

  • version: 4.1.1
  • node version: 12.4
  • npm (or yarn) version: yarn 1.22.4

Do you want to request a feature or report a bug?: bug

What is the current behavior?:
I import defineMessages from gatsby-plugin-intl, not from react-intl.
When running

extract-messages -l=en,fr -o src/intl -d en --flat false './src/pages/**/!(*.test).tsx'

on a page containing:

import { useIntl, FormattedMessage, 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 />,
      },
    },
  });

  return (
        <h1 className="title">
          {intl.formatMessage({
            id: "about.title",
            defaultMessage: "About me",
          })}
        </h1>
        <FormattedMessage {...messages.description} />
  )

it detects and generates only the title, not the description message:

// en.js
{
  "about": {
    "title": "About me"
  }
}

What is the expected behavior?:
I would expect:

// en.js
{
  "about": {
    "title": "About me",
    "description": "this description isn't picked up",
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions