Skip to content

Commit

Permalink
Allows use of translation keys in task priority labels
Browse files Browse the repository at this point in the history
  • Loading branch information
garethbowen authored and dianabarsan committed Jul 3, 2018
1 parent e469f64 commit 981a7e4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
18 changes: 11 additions & 7 deletions static/js/controllers/contacts-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ angular.module('inboxControllers').controller('ContactsContentCtrl',
});
};

var translate = function(value, task) {
if (_.isString(value)) {
// new translation key style
return $translate.instant(value, task);
}
// old message array style
return TranslateFrom(value, task);
};

var getTasks = function() {
return Auth('can_view_tasks')
.then(function() {
Expand All @@ -69,13 +78,8 @@ angular.module('inboxControllers').controller('ContactsContentCtrl',
function(areTasksEnabled, tasks) {
if ($scope.selected) {
tasks.forEach(function(task) {
if (_.isString(task.title)) {
// new translation key style
task.title = $translate.instant(task.title, task);
} else {
// old message array style
task.title = TranslateFrom(task.title, task);
}
task.title = translate(task.title, task);
task.priorityLabel = translate(task.priorityLabel, task);
});
$scope.selected.areTasksEnabled = areTasksEnabled;
$scope.selected.tasks = tasks;
Expand Down
2 changes: 1 addition & 1 deletion templates/partials/contacts_content.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ <h3 translate>Tasks</h3>
hide-time="true"
heading="selected.doc.type === 'clinic' ? (task.contact && task.contact.name) : task.title"
summary="selected.doc.type === 'clinic' ? task.title : ''"
warning="task.priorityLabel | translateFrom:task"
warning="task.priorityLabel"
/>
</ul>
<div class="row" ng-show="!filteredTasks.length">
Expand Down

0 comments on commit 981a7e4

Please sign in to comment.