語系支援
https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-localization
bot.dialog('/localePicker', [
function (session) {
// Prompt the user to select their preferred locale
builder.Prompts.choice(session, "What's your preferred language?", 'English|Español|Italiano');
},
function (session, results) {
// Update preferred locale
var locale;
switch (results.response.entity) {
case 'English':
locale = 'en';
break;
case 'Español':
locale = 'es';
break;
case 'Italiano':
locale = 'it';
break;
}
session.preferredLocale(locale, function (err) {
if (!err) {
// Locale files loaded
session.endDialog(`Your preferred language is now ${results.response.entity}`);
} else {
// Problem loading the selected locale
session.error(err);
}
});
}
]);
去年得再一開始就設定好,不過目前可以在對話裡切換語系了
因為實現了在對話中就可以切換語系,故可以將 message 丟給 text analytic api 之類,讓其判斷語系後,我在於程式中做切換。
YES ! 終於 明天開始 line builder 重構2版吧!