0

I am working on the React-intl for the language translation. I have configured React-inlt in my application, it's working for the single login module. I have a separate language constant file for each module (Login, Register, Dashboard etc). I need to merge all small js/JSON file and need to generate a single js/JSON file. Because I need to import only one file, it should contain all module language data. How to achieve this one? Create appreciate.

<IntlProvider
                locale={locale.lang}
                messages={languageMsg[locale.lang]}
            >
Partha
  • 402
  • 4
  • 15
Ramesh Lamani
  • 1,117
  • 3
  • 25
  • 54
  • You can require all json files, and then merge them with Object.assign. Something like this : `const msg1 = require('./msg1.json'); const msg2 = require('./msg2.json'); const all = Object.assign({}, msg1, msg2); ... ` – Goran.it Nov 12 '18 at 10:06
  • Thanks for the reply, above codes works only merge 2 JSON file objects. How to merge 4 to 6 JSON file objects? – Ramesh Lamani Nov 12 '18 at 11:18
  • Just add additional objects after the last one : `Object.assign({}, msg1, msg2, msg3, msg4 ....)` etc – Goran.it Nov 12 '18 at 11:58

0 Answers0