How to maintain two different languages in app.js file


#1

Dear All,
I just created google action and created API gateway and testing in the simulator. I just create only two intents say Greeting Intent and Details intent. The use case is about, i just asks the name and upon input, it will greet the customer with name.
Can you please tell me where would i maintain the script. Please share any useful tutorial


#2

Take a look here:

Or here:


#3

Dear @jan,
I have tried it, I am able to see repromt is not working . I tried in jovo debugger, simulator and google home app…
This is the response in simulator
{
“fulfillmentText”: “Welcome to ABN Mortgage”,
“outputContexts”: [],
“payload”: {
“google”: {
“expectUserResponse”: true,
“richResponse”: {
“items”: [
{
“simpleResponse”: {
“ssml”: “Welcome to ABN Mortgage”
}
}
]
},
“noInputPrompts”: [
{
“ssml”: “Would you like to continue”
}
],
“userStorage”: “{“userId”:“ABwppHGAVO01d8uChUI8_UzzoA1pC1ScY66DCtZysfYUN9WixIYFaxkyfG0nWK2eE4zsQEONH9vTi5SUbbfCpYw”}”
}
}
}


#4

Dear @jan,
Sorry for the above question. I got the answer
Can you please tell me, how can i call the multilingual content in app.logic file. I made it two files say en-US.json and nl-NL.json for english and dutch respectively.
Can you please help in calling the content


#5

It’s explained in both the video and the docs I posted above: this.t('key')


#6

Dear @jan es, i can understand. Its working for me in en-US.json. I have two files say en-US.json and nl-NL.json. How can i differentiate between languages in applogic file. Will the below piece of code is applicable for both the language?
app.setHandler({
LAUNCH() {
return this.toIntent(‘GreetingIntent’);
},

GreetingIntent() {
    this.ask(this.t('welcome.speech') , this.t('welcome.reprompt'));  
},

DetailsIntent() {
    this.tell(this.t('greeting.speech', { GettingDetailsConfirmation: this.$inputs.GettingDetailsConfirmation.value }));
},

});

module.exports.app = app;

en-US.json
{
“translation”: {
“welcome”:{
“speech”:“Welcome to ABN Mortgage, Would you like to continue”,
“reprompt”:“Please say yes or no”
},
“greeting”:{
“speech”:"Hey you told {{ GettingDetailsConfirmation }} "
}
}
}

nl-NL.json
{
“translation”: {
“welcome”:{
“speech”:“Welkom bij ABN Hypotheek, Wil je verder gaan”,
“reprompt”:“Zeg alstublieft ja of nee”
},
“greeting”:{
“speech”:"Hallo, je hebt het verteld {{ GettingDetailsConfirmation }} "
}
}
}

Please help


#7

Dear @jan,
Can we please get this closed.
My doubt is, how can i refer locale (en-US or nl-NL) in my app.logic file. As i mentioned, i use the same key in both the language file. How can differentiate multilingual in app.logic.
Please help


#8

You can access the current locale with this.getLocale()

However, this is usually not necessary, as the i18n object is already set to the current locale when the intent handler is called and something like “this.t(‘welcome.speech’)” will return the expected string.