Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pluging doesn't extract all values to json #3

Closed
Tomekmularczyk opened this issue Jul 23, 2017 · 2 comments
Closed

Pluging doesn't extract all values to json #3

Tomekmularczyk opened this issue Jul 23, 2017 · 2 comments

Comments

@Tomekmularczyk
Copy link

Tomekmularczyk commented Jul 23, 2017

I have prepared a repo to demonstrate the problem:

https://github.com/Tomekmularczyk/react-starter/tree/intl

yarn intl creates json files in /static/intl/ directory but they are missing lot of messages declared with defineMessages across src directory.

@akameco
Copy link
Owner

akameco commented Jul 25, 2017

Because it will overwrite if the key already exists.

extract-messages -l=en,pl -o ./static/intl -d en --flat 'src/**/!(*.test).jsx'

{
  "src.pages.dashboard.headerTitle": "Message to greet the user.",
  "src.pages.dashboard.fourOfour": "go to 404 page",
  "src.pages.dashboard.profile": "go to profile",
  "src.pages.dashboard.profile.headerTitle": "Hello in profile!",
  "src.pages.headerTitle": "No match for {path}",
  "src.pages.dashboard": "Dashboard"
}

extract-messages -l=en,pl -o ./static/intl -d en --flat false 'src/**/!(*.test).jsx'

{
  src: {
    pages: {
      dashboard: 'Dashboard',
      headerTitle: 'No match for {path}'
    }
  }
}

In this case we can not determine if dashboard is string or object.

@akameco
Copy link
Owner

akameco commented Jul 26, 2017

I updated babel-plugin-react-intl-auto .
Added filebase option.

ref akameco/babel-plugin-react-intl-auto#4

ex:

.babelrc

{
  "plugins": [ ["react-intl-auto", { "filebase": true }] ]
}
$ rm static/intl/en.json
$ npm run intl

en.json

{
  "src": {
    "pages": {
      "Page404": {
        "headerTitle": "No match for {path}"
      },
      "dashboard": {
        "index": {
          "fourOfour": "go to 404 page",
          "headerTitle": "Message to greet the user.",
          "profile": "go to profile"
        },
        "profile": {
          "index": {
            "headerTitle": "Hello in profile!"
          }
        }
      },
      "index": {
        "dashboard": "Dashboard",
        "headerTitle": "Welcome to React"
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants