Unify the translation service

This commit is contained in:
Jean-Baptiste Dominguez 2018-09-06 15:31:22 +09:00
commit 71e530f535

View file

@ -6,7 +6,7 @@ angular
.module('bitcoincom.services')
.factory('shapeshiftService', shapeshiftService);
function shapeshiftService(shapeshiftApiService, gettext) {
function shapeshiftService(shapeshiftApiService, gettextCatalog) {
var service = {
// Variables
@ -45,7 +45,7 @@ angular
.marketInfo(service.coinIn, service.coinOut)
.then(function (response) {
if (!response || response.error) {
handleError(response, 'Invalid response', cb);
handleError(response, 'Invalid response from Shapeshift', cb);
} else {
service.marketData = response;
service.rateString = service.marketData.rate.toString() + ' ' + coinOut.toUpperCase() + '/' + coinIn.toUpperCase();
@ -57,11 +57,11 @@ angular
function shiftIt(coinIn, coinOut, withdrawalAddress, returnAddress, amount, cb) {
// Test if the amount is correct depending on the min and max
if (!amount || typeof amount !== 'number') {
cb(new Error(gettext('Amount is not defined'))));
cb(new Error(gettextCatalog.getString('Amount is not defined'))));
} else if (amount < service.marketData.minimum) {
cb(new Error(gettext('Amount is below the minimun')));
cb(new Error(gettextCatalog.getString('Amount is below the minimun')));
} else if (amount > service.marketData.maxLimit) {
cb(new Error(gettext('Amount is above the limit')));
cb(new Error(gettextCatalog.getString('Amount is above the limit')));
} else {
// Init service data
service.withdrawalAddress = withdrawalAddress;
@ -79,13 +79,13 @@ angular
shapeshiftApiService.NormalTx(service).then(function onResponse(response) {
// If error, return it
if (!response || response.error) {
handleError(response, gettext('Invalid response from Shapeshift'), cb);
handleError(response, gettextCatalog.getString('Invalid response from Shapeshift'), cb);
} else {
var txData = response;
// If the content is not that it was expected, get back an error
if (!txData || !txData.orderId || !txData.deposit) {
cb(new Error(gettext('Invalid response from Shapeshift')));
cb(new Error(gettextCatalog.getString('Invalid response from Shapeshift')));
} else {
// Get back the data
service.depositInfo = txData;
@ -103,7 +103,7 @@ angular
}
});
} else {
cb(new Error(gettext('Invalid address')));
cb(new Error(gettextCatalog.getString('Invalid address')));
}
});
}