rxaviers / react-globalize-webpack-plugin

react-globalize webpack plugin
Other
3 stars 8 forks source link

<FormatMessage/>: path parameter seems to be ignored when building project #18

Open hrimhari opened 8 years ago

hrimhari commented 8 years ago

I created a test react app using webpack with the following rendering:

class App extends React.Component { render() { return ( <div> Globalize test<br/> <FormatCurrency currency="USD">{150}</FormatCurrency> <FormatMessage path="msgTest"/> <FormatMessage path="msgTest2">Test fallback</FormatMessage> <FormatMessage variables={{ number: numberFormatter( 123.456 ) }}>{"Globalize.formatNumber: {number}"}</FormatMessage> </div> ); } };

After running webpack, the "msgTest" message doesn't get transferred from the source messages.json to the target i18n/[locale].js.

When using "writeMessages: true" in the ReactGlobalizePlugin, I get this entry in my source messages.json:

"Test fallback": "Test fallback"

...when I was expecting:

"msgTest2": "Test fallback"

When I then try to run the App in the browser, I get:

vendor.js:5550 Uncaught TypeError: Cannot read property 'apply' of undefined

...which happens in:

Globalize.prototype.formatMessage = function( path /* , variables */ ) { return this.messageFormatter( path ).apply( {}, [].slice.call( arguments, 1 ) ); };

Thank you, Felipe

rxaviers commented 8 years ago

Thank you for filing this issue.

This plugin has had significant tests using the default message (i.e., no path property, the message itself becomes the key), but very few (to none) using the path property.

I'll look into it in the next coming days and will give you a better response.