ionic-framework


Ionic JavaScript Google Translate API


I am trying to translate words in my Ionic JavaScript App with the following code:
const Translate = require('#google-cloud/translate');
const projectId = 'YOUR_PROJECT_ID';
const translateClient = Translate({
projectId: projectId
});
const text = 'Hello, world!';
const target = 'ru';
translateClient.translate(text, target)
.then((results) => {
const translation = results[0];
console.log(`Text: ${text}`);
console.log(`Translation: ${translation}`);
})
.catch((err) => {
console.error('ERROR:', err);
});
but in the console I get the error " ReferenceError: require is not defined"
what is wrong with the above code?
Thanks!

Related Links

Use custom icons with tabs in ionic2
How to add values to select component and get seleted option in Appery ionic app
Ionic testing Slides, Cannot read property 'subscribe' of undefined at initEvents
How can i make a view to always keep all data unless explicitly flushed?
Ionic 2 build android error — gradle-wrapper.properties File not find
Ionic: how to make my sub-page bookmarkable?
Ionic package build failed - ionic-plugin-keyboard
Can we change number of tabs by using *ngIf in ionic2 dynamically
ionic header bar scroll
Ionic 3 - Entering a deep link renders the page before the app initializes
Ionic2 - using a starter by specifying a github url fails with “cannot read property”
ion-nav-back-button not working in ionic v1
ionic app not loading updated html when using iframe
What does the .tmp folder in Ionic 2 do?
Ionic Cropping Error
When applying lockSwipes, I cannot scroll image in X-axis

Categories

HOME
xamarin
image
push-notification
relayjs
jira
yarn
c#-2.0
ravendb
directx
facebook-messenger-bot
communication
nano-server
midi
wheelnav.js
php-7.1
jplayer
leiningen
flask-wtforms
iolanguage
apache-metamodel
karma-jasmine
lldb
paging
java-3d
arabic
microsoft-r
h2db
fish
pepper
virtualdub
ping
unboundid
nat
uisplitview
normal-distribution
mpmediaquery
html5-fullscreen
jmonkeyengine
ios5
dartium
hot-module-replacement
espeak
objectlistview
sharefile
twitch
elasticsearch-plugin
elmah
janrain
flashair
qcombobox
menuitem
scrollable
pubmed
dandelion
dropbox-php
dotnetzip
git-diff
jxcore
media-player
r-forge
windows-iot-core-10
memory-alignment
crosswalk-runtime
intrusion-detection
storekit
hill-climbing
livequery
vhd
collapse
simple-framework
ibaction
createprocessasuser
generic-programming
angular-local-storage
pretty-print
streambase
qcodo
nsbutton
titanium-modules
preferences
seaside
openlaszlo
aqtime
mylyn
lcs
ocunit
e4x
asyncfileupload
tomcat-valve
netbeans-7.1
visitor-statistic
site.master
blitz++
coda-slider
jquery-ui-droppable
castle-monorail
firefox-5
ti-dsp
premature-optimization
gacutil
zune
.net-1.0
paul-graham
ajax-forms

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile