You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry, if I missed something, but is there, or will there be a way to extract a messages and build a translation.json files?
I mean something like what react-boilerplate do with command extract-intl ? Or what is recommendations to generate the files?
I may be wrong, but I checked the code and, it seems to me, that adding defineMessages may make this project compatible with babel-plugin-react-intl, isn't it ?
The though is based on this lines . Can we replace the name and get the results?
Hi here again!
I was able to successfully switch to your project from react-intl! thanks! (with few things to be aware, though)
It turns out that we actually can use babel-plugin-react-intl and logic with defineMessages with this react-intl-universal as well, the only problem I faced was with the fact that there is no defineMessages function here, and my attempted to add one failed, because if we import defineMessages from this repo that will broke the extract-intl with error about "window" being undefined. If I get it right, this project doesn't meant to work on server side yet?
I ended up adding a project just to separate defineMessages, hope we will come with something better )
Actually, I'm also researching if there's better way to extract messages. I hadn't use extract-intl before. But I will try your example first these days then fulfill this feature.
By the way, could you please tell me what's "few things to be aware" you mentioned?
@cwtuan, thanks,
sure, I thought, to list them, but then thought, that I could have missed something... (correct me, please, if I am wrong somewhere with this)
in react-intl-universal the work with date and datetime just differ, there is no FormattedTime, FormattedDate. And no stright way to use react-intl-universal to render formatted time without adding a line in translation.json . In my case, I am using momentjs as well, so I replaced my usage of FormattedTime as FormattedDate with momentJsObjectWithTime.format('LT') and .format('L') respectfully.
react-intl allows to pass react objects as values for messages with variables, I may missed something, but with straight replacing FormattedHTMLMessage with .fromatHTMLMessage a got [Object] [object] . I still didn't resolve this, and wanted to open an issue to ask, but I think for my case I will be able to workaround somehow even if we will not be able to support the feature.
the part with defineMessages mentioned in this issue
the synchronization of the components with changed locale, if I get it right, one of your recommendations to this is reloading the page, as you do in demo, but that may be not what people expect with react, I was able to solve this easily, because I use mobx-react with MST I just added a prop locale={store.locale} to all components with calls to intl and it worked fine.
As for my example of extract-intl it is not complete in my repository, you can look for it the original react-boilerplate extract-intl I only changed paths to fit my structure, removed unnecessary parts that change other files expect actual translation json(s) and added a right name for the repository from which difineMessages is imported
Activity
ArsSirek commentedon Jun 22, 2017
Hi here again!
I was able to successfully switch to your project from react-intl! thanks! (with few things to be aware, though)
It turns out that we actually can use babel-plugin-react-intl and logic with defineMessages with this react-intl-universal as well, the only problem I faced was with the fact that there is no defineMessages function here, and my attempted to add one failed, because if we import defineMessages from this repo that will broke the extract-intl with error about "window" being undefined. If I get it right, this project doesn't meant to work on server side yet?
I ended up adding a project just to separate defineMessages, hope we will come with something better )
cwtuan commentedon Jun 22, 2017
Thanks for the suggestion.
Actually, I'm also researching if there's better way to extract messages. I hadn't use
extract-intlbefore. But I will try your example first these days then fulfill this feature.By the way, could you please tell me what's "few things to be aware" you mentioned?
ArsSirek commentedon Jun 22, 2017
@cwtuan, thanks,
sure, I thought, to list them, but then thought, that I could have missed something... (correct me, please, if I am wrong somewhere with this)
As for my example of extract-intl it is not complete in my repository, you can look for it the original react-boilerplate extract-intl I only changed paths to fit my structure, removed unnecessary parts that change other files expect actual translation json(s) and added a right name for the repository from which difineMessages is imported
cwtuan commentedon Jun 25, 2017
@ArsSirek Thanks for your comment. It really help me a lot to improve this project. I will take your suggestions into consideration in next release.