Pluging doesn't extract all values to json
Tomekmularczyk opened this issue · 2 comments
Tomekmularczyk commented
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 commented
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 commented
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 intlen.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"
}
}
}
}