Hi,
I am looking to translate text. Like many I installed the node-red-contrib-google-translate
node with the Palette.
Then I wanted to go further and translate text into a Function node.
I found @vitalets/google-translate-api
.
I was going to install it with npm, but first, out of curiosity, and because google-translate is already installed in the Palette, I went to my node_modules
folder and saw that @vitalets/google-translate-api
is already installed (you call it a dependency I think?)
My question: how can I use this module to translate text in a Function node?
In the Github of @vitalets/google-translate-api
he describes a use with node.js:
import { translate } from '@vitalets/google-translate-api';
const { text } = await translate('Привет, мир! Как дела?', { to: 'en' });
console.log(text) // => 'Hello World! How are you?'
I replace console.log(text)
by node.warn(text)
But that's not enough
so I ran into an alert: SyntaxError: Cannot use import statement outside a module (body:line 2)
Is there a setting to add in settings.js ? or another line of javascript code to change in my Function? (It may help me in the future, when I install other modules manually)