skill-sample-nodejs-hello-world
skill-sample-nodejs-hello-world copied to clipboard
Add i18n to ASK CLI 2.0.x template
Description of changes:
Add support for i18n resolution of messages as in the master
template.
Note that although I've given this a rough test, it involved some manual testing steps for reasons described in https://github.com/alexa/ask-cli/issues/118. I think that this PR is correct as-is, but because I had to do some manual tweaking to test it, I acknowledge that there may be some missing bits that were covered up by the manual steps I took to test.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Note that I am absolutely not advocating that the new hello world template completely recreate everything that is currently in the older template. There are a lot of things in the older template that are YAGNI and not likely needed in most skills. Even having support for ALL locales is inconvenient for a getting-started skill, as it's much easier to get started with one locale and branch out to other locales as the skill matures. (I'd also argue that the util.js
file in the new template is YAGNI...evidence being that it's not even used in the template...but I won't argue it too strongly.)
But, having the i18n module and attaching it to the handlerInput
with a t()
function so that you can externalize strings is a very useful option, even for a simple hello world skill. While you could argue that this is also a case of YAGNI, I argue that even if you only support one locale, the ability to externalize strings from the request handlers is valuable on its own and sets the groundwork for when a skill may evolve past a single locale.