如何制作多语言 Dialogflow webhook/fulfillment?

How to make a multiple language Dialogflow webhook/fulfillment?

我已经用英语构建了一个 Dialogflow 应用程序。我使用 NodeJs webhook 来提供答案。

现在,我想添加一种新语言(西班牙语)。有没有办法在不复制 webhook 的情况下添加它?

是否有像 I18N 这样的预建库,我可以在其中提供翻译并根据 "languageCode": "en" 发送答案?

一般的解决方案是使用您选择的本地化库,向它发送一个字符串标识符,然后发送它生成的响应。有several libraries that Google suggests, however you should be able to use whichever one works best for you. There are some issues using i18n-node if you are using asynchronous code - the problems and solutions are also discussed by the team.

还有 multivocal library,它采用不同的方法生成响应,但内置了本地化功能。