|
19 | 19 | $scope.items = [];
|
20 | 20 | }
|
21 | 21 |
|
| 22 | + $scope.translateResult = {'total': 0, 'loading': 0, 'errors': 0, 'skip': 0, 'success': 0}; |
| 23 | + $scope.translateAll = function() { |
| 24 | + $scope.translateResult = {'total': 0, 'loading': 0, 'errors': 0, 'skip': 0, 'success': 0}; |
| 25 | + $scope.translateResult.total = $scope.items.length; |
| 26 | + var requests = 0; |
| 27 | +
|
| 28 | + for(key in $scope.items) { |
| 29 | + $scope.translateResult.loading++; |
| 30 | + if($scope.items[key].translation === null || $scope.items[key].translation === '') { |
| 31 | + requests++; |
| 32 | + setTimeout(function(key){ |
| 33 | + $scope.translate($scope.items[key].value, $scope.items[key].name, function(data) { |
| 34 | + $scope.translateResult.loading--; |
| 35 | + $scope.translateResult.success++; |
| 36 | + for(i in $scope.items) { |
| 37 | + if($scope.items[i].name === data.key) { |
| 38 | + $scope.items[i].translation = data.text; |
| 39 | + $scope.items[i].check = true; |
| 40 | + } |
| 41 | + } |
| 42 | + }, function() { |
| 43 | + $scope.translateResult.loading--; |
| 44 | + $scope.translateResult.errors++; |
| 45 | + }); |
| 46 | + }, 500*requests, key); |
| 47 | + } else { |
| 48 | + $scope.translateResult.loading--; |
| 49 | + $scope.translateResult.skip++; |
| 50 | + } |
| 51 | + } |
| 52 | + }; |
| 53 | +
|
| 54 | + $scope.translate = function(text, key, success, error) { |
| 55 | + $http.post("{{ URL::route('translations.translate') }}", { |
| 56 | + 'key': key, |
| 57 | + 'origin': $scope.currentLocale, |
| 58 | + 'target': $scope.currentEditable, |
| 59 | + 'text': text |
| 60 | + }).success(success) |
| 61 | + .error(error); |
| 62 | + }; |
| 63 | +
|
22 | 64 | $scope.fetch = function() {
|
23 | 65 | $http.post("{{ URL::route('translations.items') }}", {
|
24 | 66 | 'group': $scope.currentGroup,
|
|
42 | 84 | .error(function(data, status, headers, config) {
|
43 | 85 | $scope.setMessage(status, 'danger');
|
44 | 86 | });
|
| 87 | + $scope.items[$index].check = false; |
45 | 88 | }
|
46 | 89 |
|
47 | 90 | $scope.locales = [];
|
|
0 commit comments