Extracting string on button click in react intl

36 Views Asked by At

I am currently working with a React application where I'm utilizing the react-intl library for internationalization. I've successfully set up message extraction using the following script in my package.json:

"extract": "formatjs extract \"src/**/*.{js,ts,tsx}\" --format ./src/utils/messageFormatter.js --id-interpolation-pattern '[sha512:contenthash:base64:6]' --out-file src/translations/messages/lang.json"

This script extracts messages from the source files and generates a JSON file containing the messages.

However, I now have a requirement where I want to trigger the message extraction process on a button click, all while following best practices. My goal is to initiate the script execution in response to the button click event.

Could anyone provide guidance on how I can achieve this? I'm looking for a secure and maintainable approach that adheres to industry best practices.

Thank you for your help!

0

There are 0 best solutions below