Localizing Spoken Responses

In Chapter 1, Alexa, Hello, as we began work on the Star Port 75 Travel skill, we added a LocalisationRequestInterceptor object in index.js and registered it with the skill builder. As a reminder, here’s what LocalisationRequestInterceptor looks like:

 const​ LocalisationRequestInterceptor = {
  process(handlerInput) {
  i18n.init({
  lng: Alexa.getLocale(handlerInput.requestEnvelope),
  resources: languageStrings
  }).then((t) => {
  handlerInput.t = (...args) => t(...args);
  });
  }
 };

The ASK SDK gives us the option of registering one or more request intercepters in the skill. Such interceptors may inspect and modify the handlerInput object before giving it to a request handler. ...

Get Build Talking Apps for Alexa now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.