Automate translations
utils/translate.js
import { translateProject } from 'translate-projects-react';
translateProject({
sourceLang: 'es', // Default language
targetLangs: ['en'], // Languages to translate
apiKey: '#', //Your API key
scanner: true // We enabled the scanner.
});
Set up command for npm
Add the following command in your package.json
file:
package.json
"scripts": {
"translate": "node ./utils/translate.js"
}
To avoid an error in loading the modules, go to your package.json
and add the type as module
.
package.json
{
...Your settings,
"type": "module",
}
We execute the command for our translations to be carried out.
Terminal
npm run translate