notifications: translate messages prefixed with tr:

This commit is contained in:
Girish Ramakrishnan
2021-06-23 21:59:30 -07:00
parent baf543ba00
commit 1a406c4d7d
+9 -5
View File
@@ -3,7 +3,7 @@
/* global async */
/* global angular */
angular.module('Application').controller('NotificationsController', ['$scope', '$timeout', 'Client', function ($scope, $timeout, Client) {
angular.module('Application').controller('NotificationsController', ['$scope', '$timeout', '$translate', 'Client', function ($scope, $timeout, $translate, Client) {
$scope.clearAllBusy = false;
$scope.notifications = [];
@@ -20,11 +20,15 @@ angular.module('Application').controller('NotificationsController', ['$scope', '
// collapse by default
result.forEach(function (r) { r.isCollapsed = true; });
// attempt to parse the message as json
// attempt to translate or parse the message as json
result.forEach(function (r) {
try {
r.messageJson = JSON.parse(r.message);
} catch (e) {}
if (r.message.slice(0, 3) === 'tr:') {
r.message = $translate.instant(r.message.slice(3));
} else {
try {
r.messageJson = JSON.parse(r.message);
} catch (e) {}
}
});
$scope.notifications = result;