Today, we are excited to announce five new SSML tags in the US, UK, and Germany that you can use with Alexa, including whispers, expletive bleeps, and more.[Read More]
In this article, we’ll review two concepts: 1) separating content from logic and 2) using the locale attribute to serve the right content to the right users.
As an example, I’ve made a new skill: Classical Guitar Facts (using this template), which has content in both English and German. Although one might assume that I could get away with US English in the UK, differences in spelling and word choice will show up in the cards within the Alexa app, and this is not the best user experience. So, we’ll create content files in three separate folders, one per language, as shown below.
Moving the content out of the index.js files means that I’ve copied the FACTS array into a separate file and saved the file as de-facts.js, gb-facts.js, and us-facts.js respectively. Remember the last item in the FACTS array does not have a comma at the end. Also, remember the last line of this file “module.exports = FACTS”, otherwise the calling file (index.js) won’t be able to find it.
var FACTS = [ "The strings of guitars are often called gut strings because…”, " …”, " …” ]; module.exports = FACTS;
At the top of the index.js file, we need to declare the FACTS variable:
var FACTS = [ ];
so that we can call it later like this:
FACTS = require('./content/en-US/us-facts.js');
Of course, we can substitute en-US/us-facts.js with en-GB/gb-facts.js and de-DE/de-facts.js when needed. Now we’re well organized to swap separate content files based on language – but how do we know which language is calling our service?[Read More]