forked from Accenture/alexia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi-language-app.js
41 lines (33 loc) · 916 Bytes
/
multi-language-app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
'use strict';
const i18next = require('i18next');
const FilesystemBackend = require('i18next-node-fs-backend');
const alexia = require('../..');
const app = alexia.createApp();
// Initialize i18next internationalization
i18next
.use(FilesystemBackend)
.init({
// debug: true,
lng: 'en',
fallbackLng: 'en',
backend: {
loadPath: 'locales/{{lng}}/{{ns}}.json' // Path is relative to your current working directory - change it accordingly
},
preload: ['en', 'de'],
ns: ['translation', 'custom-slots']
});
// Pass i18 to alexia app to make it available for requests and speech assets generation
app.setI18next(i18next);
app.onStart(() => {
return app.t('text');
});
app.onEnd(() => {
return app.t('text');
});
app.intent('LocalizedIntent', slots => {
return app.t('text', slots);
});
app.builtInIntent('yes', () => {
return app.t('text');
});
module.exports = app;