我希望有人能帮助我。我试图创造一种多语言的Alexa技能。
我的主文件中有一些语言常量,如Alexa提供的示例代码所示:
const languageString = {
'en': {
'translation': {
'QUESTIONS': questions['QUESTIONS_EN_US'],
'GAME_NAME': 'My Quiz', // Be sure to change this for your skill.
'HELP_MESSAGE': 'I will ask you %s multiple choice questions. Respond with the number of the answer. ' +
'For example, say one, two, three, or four. To start a new game at any time, say, start game. ',
一切都很好,所以我现在想添加一些替代字符串,这样游戏就不那么无聊了。所以我创建了一个正确的。js文件,并在我的文档中定义如下:
const correct = require('./correct');
此文件如下所示:
'use strict';
module.exports = {
CORRECT_EN_GB: [
"Booya", "All righty", "Bam", "Bazinga", "Bingo", "Boom", "Bravo", "Cha Ching", "Cheers", "Dynomite",
"Hip hip hooray", "Hurrah", "Hurray", "Huzzah", "Oh dear. Just kidding. Hurray", "Kaboom", "Kaching", "Oh snap", "Phew",
"Righto", "Way to go", "Well done", "Whee", "Woo hoo", "Yay", "Wowza", "Yowsa"
],
CORRECT_EN_US: [
"Booya", "All righty", "Bam", "Bazinga", "Bingo", "Boom", "Bravo", "Cha Ching", "Cheers", "Dynomite",
"Hip hip hooray", "Hurrah", "Hurray", "Huzzah", "Oh dear. Just kidding. Hurray", "Kaboom", "Kaching", "Oh snap", "Phew",
"Righto", "Way to go", "Well done", "Whee", "Woo hoo", "Yay", "Wowza", "Yowsa"
],
CORRECT_DE_DE: [
"Aber hallo", "Bazinga", "Bingo", "Bravo", "Donnerwetter",
"en garde", "hipp hipp hurra", "hurra", "japp", "jawohl", "jo", "juhu", "na sieh mal einer an", "Stimmt",
"Super", "Supi", "tada", "türlich", "yay"
],
};
现在,我想在我的语言字符串中检索列表的随机值,并尝试了以下代码:
'ANSWER_CORRECT_MESSAGE': '<say-as interpret-as="interjection">' + correct['CORRECT_EN_US'][Math.floor(Math.random() * correct['CORRECT_EN_US'].length)] + '</say-as><break time="1s"/> your reply is correct.<break time="2s"/>',
谁能帮我找到正确的密码?非常感谢。
酶联免疫吸附试验