Commit d2146031da53ac0337a80ac7ce8b47b8e2f68d72

Authored by Wesnydy Ribeiro
1 parent 15037cba
Exists in OpenSigns

Api language param

translate-api/config/settings.js
@@ -15,6 +15,8 @@ var config = {}; @@ -15,6 +15,8 @@ var config = {};
15 config.contentsPath = process.env.VLIBRAS_VIDEO_LIBRAS; 15 config.contentsPath = process.env.VLIBRAS_VIDEO_LIBRAS;
16 config.bundlesPath = process.env.SIGNS_VLIBRAS; 16 config.bundlesPath = process.env.SIGNS_VLIBRAS;
17 17
  18 +config.defaultLang = "pt-br"
  19 +
18 config.platformsList = [ 'ANDROID', 'IOS', 'WEBGL', 'STANDALONE' ]; 20 config.platformsList = [ 'ANDROID', 'IOS', 'WEBGL', 'STANDALONE' ];
19 21
20 config.statesList = [ 'AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO', 22 config.statesList = [ 'AC', 'AL', 'AP', 'AM', 'BA', 'CE', 'DF', 'ES', 'GO',
translate-api/controllers/translate.js
@@ -10,16 +10,19 @@ @@ -10,16 +10,19 @@
10 */ 10 */
11 var shortid = require('shortid') 11 var shortid = require('shortid')
12 , amqp = require('../helpers/amqpManager') 12 , amqp = require('../helpers/amqpManager')
13 - , error = require('../helpers/error'); 13 + , error = require('../helpers/error')
  14 + , settings = require('../config/settings');
14 15
15 exports.translate = function(req, res, next) { 16 exports.translate = function(req, res, next) {
16 if (!req.body.text) 17 if (!req.body.text)
17 return error.badRequest('The text key is missing.', next); 18 return error.badRequest('The text key is missing.', next);
18 19
19 - var id = shortid.generate();  
20 - var text = req.body.text; 20 + var params = {};
  21 + params.id = shortid.generate();
  22 + params.text = req.body.text;
  23 + params.lang = req.body.lang ? req.body.lang : settings.defaultLang;
21 24
22 - amqp.sendToQueue(text, id,'texts', false, res, function(err) { 25 + amqp.sendToQueue(JSON.stringify(params), id,'texts', false, res, function(err) {
23 if (err) 26 if (err)
24 return error.internalError('An internal communication error has occurred.', next); 27 return error.internalError('An internal communication error has occurred.', next);
25 amqp.receiveFromQueue(id, 'translations', false, res, function(err, message) { 28 amqp.receiveFromQueue(id, 'translations', false, res, function(err, message) {