From c4b4dd4d50e9ebb4d8f340f947c3512350695693 Mon Sep 17 00:00:00 2001 From: hamza zia Date: Mon, 2 May 2016 10:35:47 +0800 Subject: [PATCH] added translation for more alerts --- js/services/rpc/rpc.js | 16 +++++++++------- js/translate/en_US.js | 9 ++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/js/services/rpc/rpc.js b/js/services/rpc/rpc.js index 6d7792c..851b0a9 100644 --- a/js/services/rpc/rpc.js +++ b/js/services/rpc/rpc.js @@ -5,8 +5,8 @@ angular ]) .factory('$rpc', [ '$syscall', '$globalTimeout', '$alerts', '$utils', - '$rootScope', '$location', '$authconf', -function(syscall, globalTimeout, alerts, utils, rootScope, uri, authconf) { + '$rootScope', '$location', '$authconf', '$filter', +function(syscall, globalTimeout, alerts, utils, rootScope, uri, authconf, filter) { var subscriptions = [] , configurations = [authconf] @@ -102,11 +102,13 @@ function(syscall, globalTimeout, alerts, utils, rootScope, uri, authconf) { // If some proposed configurations are still in the pipeline then retry if (configurations.length) { - alerts.log("The last connection attempt was unsuccessful. Trying another configuration"); + alerts.log(filter('translate')("The last connection attempt was unsuccessful. Trying another configuration")); timeout = setTimeout(update, 0); } else { - alerts.addAlert('Oh Snap! Could not connect to the aria2 RPC server. Will retry in 10 secs. You might want to check the connection settings by going to Settings > Connection Settings', 'error'); + alerts.addAlert('' + filter('translate')('Oh Snap!') + ' ' + + filter('translate')('Could not connect to the aria2 RPC server. Will retry in 10 secs. You might want to check the connection settings by going to Settings > Connection Settings') + , 'error') timeout = setTimeout(update, globalTimeout); } }; @@ -129,9 +131,9 @@ function(syscall, globalTimeout, alerts, utils, rootScope, uri, authconf) { // configuration worked, save it in cookie for next time and // delete the pipelined configurations!! if (currentToken) - alerts.addAlert('Successfully connected to Aria2 through its remote RPC …', 'success'); + alerts.addAlert(filter('translate')('Successfully connected to Aria2 through its remote RPC …'), 'success'); else - alerts.addAlert('Successfully connected to Aria2 through remote RPC, however the connection is still insecure. For complete security try adding an authorization secret token while starting Aria2 (through the flag --rpc-secret)'); + alerts.addAlert(filter('translate')('Successfully connected to Aria2 through remote RPC, however the connection is still insecure. For complete security try adding an authorization secret token while starting Aria2 (through the flag --rpc-secret)')); configurations = []; } @@ -180,7 +182,7 @@ function(syscall, globalTimeout, alerts, utils, rootScope, uri, authconf) { // each one will be tried one after the other till success, // for all options for one conf read rpc/syscall.js configure: function(conf) { - alerts.addAlert('Trying to connect to aria2 using the new connection configuration', 'info'); + alerts.addAlert(filter('translate')('Trying to connect to aria2 using the new connection configuration'), 'info'); if (conf instanceof Array) configurations = conf; diff --git a/js/translate/en_US.js b/js/translate/en_US.js index 5f3b026..2731047 100644 --- a/js/translate/en_US.js +++ b/js/translate/en_US.js @@ -133,5 +133,12 @@ translations.en_US = { 'Download GID':'Download GID', 'Number of Pieces':'Number of Pieces', 'Piece Length': 'Piece Length', - 'Shutdown Server': 'Shutdown Server' + 'Shutdown Server': 'Shutdown Server', + + 'The last connection attempt was unsuccessful. Trying another configuration': 'The last connection attempt was unsuccessful. Trying another configuration', + 'Oh Snap!': 'Oh Snap!', + 'Could not connect to the aria2 RPC server. Will retry in 10 secs. You might want to check the connection settings by going to Settings > Connection Settings': 'Could not connect to the aria2 RPC server. Will retry in 10 secs. You might want to check the connection settings by going to Settings > Connection Settings', + 'Successfully connected to Aria2 through its remote RPC …': 'Successfully connected to Aria2 through its remote RPC …', + 'Successfully connected to Aria2 through remote RPC, however the connection is still insecure. For complete security try adding an authorization secret token while starting Aria2 (through the flag --rpc-secret)': 'Successfully connected to Aria2 through remote RPC, however the connection is still insecure. For complete security try adding an authorization secret token while starting Aria2 (through the flag --rpc-secret)', + 'Trying to connect to aria2 using the new connection configuration': 'Trying to connect to aria2 using the new connection configuration', };