Multi language support changed to a custom.

This commit is contained in:
Rodrigo Rodriguez 2018-09-13 19:58:18 -03:00
parent d3487387d6
commit c573e33754
5 changed files with 31 additions and 35 deletions

View file

@ -35,8 +35,7 @@
import { IGBDialog } from "botlib"
import { GBMinInstance } from "botlib"
import { BotAdapter } from "botbuilder"
const localize = require("localize")(__dirname)
const _T = localize.translate
const messages = require("./strings.json").messages
export class WelcomeDialog extends IGBDialog {
/**
@ -52,17 +51,18 @@ export class WelcomeDialog extends IGBDialog {
async (dc, args) => {
const user = min.userState.get(dc.context)
localize.setLocale(dc.context.activity.locale.split("-")[0])
let loc = dc.context.activity.locale;
if (!user.once) {
user.once = true
var a = new Date()
const date = a.getHours()
var msg =
date < 12 ? _T("good morning") : date < 18 ? localize.translate("good evening") : _T("good night")
date < 12 ? messages[loc].good_morning : date < 18 ?
messages[loc].good_evening : messages[loc].good_night
let messages = [`Oi, ${msg}.`, `Oi!`, `Olá, ${msg}`, `Olá!`]
await dc.context.sendActivity(messages[0])
let messages1 = [`Oi, ${msg}.`, `Oi!`, `Olá, ${msg}`, `Olá!`]
await dc.context.sendActivity(messages1[0])
if (dc.context.activity && dc.context.activity.type == "message" &&
dc.context.activity.text != "") {

View file

@ -0,0 +1,16 @@
{
"messages": {
"en-US": {
"show_video": "I will show you a video, please wait...",
"good_morning": "good morning",
"good_evening": "good evening",
"good_night": "good night"
},
"pt-BR": {
"show_video": "Vou te mostrar um vídeo. Por favor, aguarde...",
"good_morning": "bom dia",
"good_evening": "boa tarde",
"good_night": "boa noite"
}
}
}

View file

@ -1,14 +0,0 @@
{
"I will show you a video, please wait...": {
"pt": "Vou te mostrar um vídeo. Por favor, aguarde..."
},
"good morning": {
"pt": "bom dia"
},
"good evening": {
"pt": "boa tarde"
},
"good night": {
"pt": "boa noite"
}
}

View file

@ -36,6 +36,7 @@ const { TextPrompt } = require("botbuilder-dialogs")
const UrlJoin = require("url-join")
const express = require("express")
const logger = require("../../../src/logger")
const request = require('request-promise-native')
import {
BotFrameworkAdapter,
@ -47,7 +48,6 @@ import {
import { GBCoreService } from "./GBCoreService"
import { GBConversationalService } from "./GBConversationalService"
import * as request from "request-promise-native"
import { GBMinInstance, IGBPackage } from "botlib"
import { GBAnalyticsPackage } from "../../analytics.gblib"
import { GBCorePackage } from "../../core.gbapp"

View file

@ -3,26 +3,23 @@
"allowJs": false,
"baseUrl": "./",
"declaration": false,
"allowSyntheticDefaultImports": true,
"esModuleInterop" : true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"mapRoot": "./dist/",
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"outDir": "./dist",
"paths": {
"botlib/*": [
"node_modules/botlib/*"
],
"pragmatismo-io-framework/*": [
"node_modules/pragmatismo-io-framework/*"
]
"botlib/*": ["node_modules/botlib/*"],
"pragmatismo-io-framework/*": ["node_modules/pragmatismo-io-framework/*"]
},
"sourceMap": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
]
"typeRoots": ["node_modules/@types"]
},
"include": [
"test/**/*",
@ -30,8 +27,5 @@
"deploy/*.gbapp/**/*",
"deploy/*.gblib/**/*"
],
"exclude": [
"dist",
"node_modules"
]
"exclude": ["dist", "node_modules"]
}