alexa-app
alexa-app copied to clipboard
Implement localization support
I plan to develop a Skill which should be reusable for both German and English. Of course I don't want to deploy it twice, but I want to be able to switch it dynamically at run time.
Would it be possible to introduce a URL parameter like "?locale=de" which I could add to the URL, which is then accessible in the request
variable? Or is there already a way to get the express server's request object?
I've never done this personally, but the Alexa skill localization seems to be fairly straightforward as described in https://developer.amazon.com/blogs/post/Tx2XUAQ741IYQI4/how-to-build-a-multi-language-alexa-skill. You get event.request.locale
and you can respond accordingly.
Would love whatever code is needed in alexa-app to support that, but I don't think support for ?locale=de
is that code. I could be wrong.
It seems that it's not even possible to append GET parameters - Alexa then told me that she couldn't resolve my host name. As request.data.request.locale
is set to de-DE
, this should do it, if you ask me now. I wasn't aware of this property and appreciate your hint :)
Update: of course one has to handle the generation of slots+utterances then. But I'm not sure if making this easier is the purpose of this great alexa-app project.
I'd love to have a section in the README on how to support multiple languages. Whatever that takes. And some new code ;)
Having the same challenge. I'm using i18n and instantiate it in app.pre (using the alexa-app-router as well)
function pre (req, res) {
i18n.configure({
locales: ['en-US', 'en-GB', 'de-DE'],
objectNotation: true,
directory: __dirname + '/../locales',
register: req
})
i18n.setLocale(req.data.request.locale)
Then I can use it in any handler with req.__('launch.welcome', config.appName)
I looked in @sibbl solution in his akinator project. The solution to generate the different utterances is kinda smart but still a workaround. Would love to see support in alexa-app/*-server directly as it is also a feature of Alexa and not just an afterthought.
@siedi can you post a full example with the Launch-Intent for instance please? Would be awesome! I still have some questions and not sure if I understand or can implement your solution properly. Thank you very much!