diff options
author | brantje <brantje@gmail.com> | 2016-12-21 16:06:29 +0300 |
---|---|---|
committer | brantje <brantje@gmail.com> | 2016-12-21 16:06:29 +0300 |
commit | b1aebc4a1452d950a5c8f63629e129f17caf5986 (patch) | |
tree | d5a32ef9a39bcbe0adbbd8e8f0b4c7ed801fa440 /js/app/directives | |
parent | 5e119ff7ed7191acb6626f96c2bba3de7a9393d7 (diff) |
Add translations to javascript files
Diffstat (limited to 'js/app/directives')
-rw-r--r-- | js/app/directives/credentialfield.js | 14 | ||||
-rw-r--r-- | js/app/directives/passwordgen.js | 13 | ||||
-rw-r--r-- | js/app/directives/progressbar.js | 8 |
3 files changed, 23 insertions, 12 deletions
diff --git a/js/app/directives/credentialfield.js b/js/app/directives/credentialfield.js index 72590f34..ae380236 100644 --- a/js/app/directives/credentialfield.js +++ b/js/app/directives/credentialfield.js @@ -30,7 +30,7 @@ */ angular.module('passmanApp') - .directive('credentialField', ['$timeout', function ($timeout) { + .directive('credentialField', ['$timeout', '$translate', function ($timeout, $translate) { return { scope: { value: '=value', @@ -45,13 +45,17 @@ '<span ng-if="valueVisible">{{value}}</span>' + '</div>' + '<div class="tools">' + - '<div class="cell" ng-if="toggle" tooltip="\'Toggle visibility\'" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': !valueVisible, \'fa-eye-slash\': valueVisible }"></i></div>' + + '<div class="cell" ng-if="toggle" tooltip="tggltxt" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': !valueVisible, \'fa-eye-slash\': valueVisible }"></i></div>' + '<div class="cell" ng-if="isLink"><a ng-href="{{value}}" target="_blank"><i tooltip="\'Open in new window\'" class="link fa fa-external-link"></i></a></div>' + '<div class="cell" ngclipboard-success="onSuccess(e);" ngclipboard-error="onError(e);" ngclipboard data-clipboard-text="{{value}}"><i tooltip="copy_msg" class="fa fa-clipboard"></i></div>' + '</div></span>', link: function (scope) { var expression = /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/gi; var regex = new RegExp(expression); + $translate(['toggle.visibility', 'copy', 'copied']).then(function (translations) { + scope.tggltxt = translations['toggle.visibility']; + scope.copy_msg = translations['copy']; + }); scope.$watch("value", function () { if (scope.value) { @@ -69,13 +73,13 @@ scope.toggle = true; } } - scope.copy_msg = 'Copy to clipboard'; + var timer; scope.onSuccess = function () { - scope.copy_msg = 'Copied to clipboard!'; + scope.copy_msg = $translate.instant('copied') ; $timeout.cancel(timer); timer = $timeout(function () { - scope.copy_msg = 'Copy to clipboard'; + scope.copy_msg = $translate.instant('copy'); }, 5000); }; scope.valueVisible = true; diff --git a/js/app/directives/passwordgen.js b/js/app/directives/passwordgen.js index 10fa481a..65fbe9b2 100644 --- a/js/app/directives/passwordgen.js +++ b/js/app/directives/passwordgen.js @@ -31,7 +31,7 @@ */ angular.module('passmanApp') - .directive('passwordGen', function ($timeout) { + .directive('passwordGen', function ($timeout, $translate) { /* jshint ignore:start */ function Arcfour () { this.j = this.i = 0, this.S = [] @@ -152,8 +152,8 @@ "<input ng-show=\"passwordVisible\" type=\"text\" ng-disabled=\"disabled\" class=\"form-control \" ng-model=\"password\" placeholder=\"{{placeholder}}\">" + '<span class="generate_pw">' + - '<div class="cell" tooltip="\'Generate password\'" ng-click="generatePasswordStart()"><i class="fa fa-refresh"></i></div>' + - '<div class="cell" tooltip="\'Toggle password visibility\'" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': passwordVisible, \'fa-eye-slash\': !passwordVisible }"></i></div>' + + '<div class="cell" tooltip="gen_msg" ng-click="generatePasswordStart()"><i class="fa fa-refresh"></i></div>' + + '<div class="cell" tooltip="tggltxt" ng-click="toggleVisibility()"><i class="fa" ng-class="{\'fa-eye\': passwordVisible, \'fa-eye-slash\': !passwordVisible }"></i></div>' + '<div class="cell" tooltip="\'Copy password to clipboard\'"><i class="fa fa-clipboard" ngclipboard-success="onSuccess(e);" ngclipboard-error="onError(e);" ngclipboard data-clipboard-text="{{password}}"></i></div>' + "</button>" + "</div>" + @@ -177,6 +177,11 @@ } }); + $translate(['password.gen', 'password.copy', 'copied', 'toggle.visibility']).then(function (translations) { + scope.tggltxt = translations['toggle.visibility']; + scope.copy_msg = translations['password.copy']; + scope.gen_msg = translations['password.gen']; + }); scope.$watch("password", function () { scope.model = scope.password; @@ -185,7 +190,7 @@ // scope.onSuccess = function (e) { //@TODO move OC.Notification to a service - OC.Notification.showTemporary('Password copied to clipboard!'); + OC.Notification.showTemporary($translate.instant('password.copied')); e.clearSelection(); }; diff --git a/js/app/directives/progressbar.js b/js/app/directives/progressbar.js index 6b6d6fb8..b7870cf7 100644 --- a/js/app/directives/progressbar.js +++ b/js/app/directives/progressbar.js @@ -29,13 +29,13 @@ * # passwordGen */ angular.module('passmanApp') - .directive('progressBar', [function () { + .directive('progressBar', [function ($translate) { return { restrict: 'A', template: '' + '<div class="progress">' + '<div class="progress-bar" role="progressbar" aria-valuenow="{{progress}}"aria-valuemin="0" aria-valuemax="100" style="width:{{progress}}%;" use-theme>' + - '<span class="sr-only">{{progress}}% Complete</span>' + + '<span class="sr-only">{{progress}}% {{completed_text}}</span>' + '<span ng-if="index && total" class="progress-label" use-theme type="\'color\'" color="\'true\'">{{index}} / {{total}}</span>' + '<span ng-if="!index && !total" class="progress-label" use-theme type="\'color\'" color="\'true\'">{{progress}}%</span>' + '</div>' + @@ -47,7 +47,9 @@ }, link: function () { - + $translate(['complete']).then(function (translations) { + $scope.completed_text = translations['complete']; + }) } }; }]); |