diff --git a/static/js/controllers/chatroomcontroller.js b/static/js/controllers/chatroomcontroller.js
index d6611ef8..68e25526 100644
--- a/static/js/controllers/chatroomcontroller.js
+++ b/static/js/controllers/chatroomcontroller.js
@@ -46,6 +46,8 @@ define(['jquery', 'underscore', 'moment', 'text!partials/fileinfo.html', 'text!p
}, 100));
var displayName = safeDisplayName;
+ // To be used by chatroom.html partial.
+ $scope.displayName = displayName;
var buddyImageSrc = $filter("buddyImageSrc");
var fileInfo = $compile(templateFileInfo);
var contactRequest = $compile(templateContactRequest);
@@ -415,9 +417,9 @@ define(['jquery', 'underscore', 'moment', 'text!partials/fileinfo.html', 'text!p
case "LeftOrJoined":
$scope.showtime(new Date());
if (data.LeftOrJoined === "left") {
- $scope.display(null, $("" + displayName(from) + translation._(" is now offline.") + ""));
+ $scope.display(null, $("" + translation._("%1$s is now offline.", displayName(from)) + ""));
} else {
- $scope.display(null, $("" + displayName(from) + translation._(" is now online.") + ""));
+ $scope.display(null, $("" + translation._("%1$s is now online.", displayName(from)) + ""));
}
break;
case "Log":
diff --git a/static/js/controllers/statusmessagecontroller.js b/static/js/controllers/statusmessagecontroller.js
index a9af9717..28889dd5 100644
--- a/static/js/controllers/statusmessagecontroller.js
+++ b/static/js/controllers/statusmessagecontroller.js
@@ -23,7 +23,10 @@
define([], function() {
// StatusmessageController
- return ["$scope", "mediaStream", function($scope, mediaStream) {
+ return ["$scope", "mediaStream", "safeDisplayName", function($scope, mediaStream, safeDisplayName) {
+
+ // To be used by statusmessage.html partial.
+ $scope.displayName = safeDisplayName;
$scope.doHangup = function(reason, id) {
mediaStream.webrtc.doHangup(reason, id);
diff --git a/static/js/controllers/uicontroller.js b/static/js/controllers/uicontroller.js
index 89a04dee..4e23d88f 100644
--- a/static/js/controllers/uicontroller.js
+++ b/static/js/controllers/uicontroller.js
@@ -512,7 +512,9 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web
// Start to ring.
ringer.start();
// Show incoming call notification.
- notification = desktopNotify.notify(translation._("Incoming call"), translation._("from") + " " + displayName(from), {
+ // TODO: This might not be correct in some languages where the
+ // name must come first.
+ notification = desktopNotify.notify(translation._("Incoming call"), translation._("from %1$s", displayName(from)), {
timeout: null
});
$scope.$emit("status", "ringing");
@@ -808,21 +810,21 @@ define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'web
var message = null;
switch (type) {
case "busy":
- message = displayName(details.from) + translation._(" is busy. Try again later.");
+ message = translation._("%1$s is busy. Try again later.", displayName(details.from));
break;
case "reject":
- message = displayName(details.from) + translation._(" rejected your call.");
+ message = translation._("%1$s rejected your call.", displayName(details.from));
break;
case "pickuptimeout":
- message = displayName(details.from) + translation._(" does not pick up.");
+ message = translation._("%1$s does not pick up.", displayName(details.from));
break;
case "incomingbusy":
- toastr.info(moment().format("lll"), displayName(details.from) + translation._(" tried to call you"));
+ toastr.info(moment().format("lll"), translation._("%1$s tried to call you", displayName(details.from)));
break;
case "abortbeforepickup":
// Fall through
case "incomingpickuptimeout":
- toastr.info(moment().format("lll"), displayName(details.from) + translation._(" called you"));
+ toastr.info(moment().format("lll"), translation._("%1$s called you", displayName(details.from)));
break;
}
if (message) {
diff --git a/static/js/directives/chat.js b/static/js/directives/chat.js
index 1da17e69..ce253c4e 100644
--- a/static/js/directives/chat.js
+++ b/static/js/directives/chat.js
@@ -24,6 +24,10 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
return ["$compile", "safeDisplayName", "mediaStream", "safeApply", "desktopNotify", "translation", "playSound", "fileUpload", "randomGen", "buddyData", "appData", "$timeout", "geolocation", function($compile, safeDisplayName, mediaStream, safeApply, desktopNotify, translation, playSound, fileUpload, randomGen, buddyData, appData, $timeout, geolocation) {
+ // Translation helpers.
+ translation._("Chat with %1$s");
+ translation._("Room chat %1$s");
+
var displayName = safeDisplayName;
var groupChatId = "";
var maxMessageSize = 200000;
@@ -138,7 +142,8 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
$scope.showGroupRoom(null, options);
} else {
$scope.showRoom(id, {
- title: translation._("Chat with")
+ // Gets translated in template.
+ title: "Chat with %1$s"
}, options);
}
@@ -160,7 +165,8 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
return;
}
var subscope = $scope.showRoom(id, {
- title: translation._("Chat with")
+ // Gets translated in template.
+ title: "Chat with %1$s"
}, options);
subscope.sendChatServer(id, "Contact request", {
ContactRequest: {
@@ -182,7 +188,8 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
scope.showGroupRoom = function(settings, options) {
var stngs = $.extend({
- title: translation._("Room chat"),
+ // Gets translated in template.
+ title: "Room chat %1$s",
group: true
}, settings);
return scope.showRoom(controller.group, stngs, options);
@@ -385,7 +392,7 @@ define(['jquery', 'underscore', 'text!partials/chat.html', 'text!partials/chatro
// before we beep and shout.
if (!subscope.isgroupchat && from !== sessionid) {
playSound.play("chatmessage");
- desktopNotify.notify(translation._("Message from ") + displayName(from), message);
+ desktopNotify.notify(translation._("Message from %1$s", displayName(from)), message);
appData.e.triggerHandler("uiNotification", ["chatmessage", {from: from, message: message, first: subscope.firstmessage}]);
}
subscope.firstmessage = false;
diff --git a/static/partials/chat.html b/static/partials/chat.html
index 5e7a2630..b76eb043 100644
--- a/static/partials/chat.html
+++ b/static/partials/chat.html
@@ -8,7 +8,7 @@
{{room.pending}}
{{room.id|displayName}}
- {{_("Room chat")}} {{currentRoomName}}
+ {{_("Room chat %1$s", currentRoomName)}}
diff --git a/static/partials/chatroom.html b/static/partials/chatroom.html
index 6f59622b..f08f85ee 100644
--- a/static/partials/chatroom.html
+++ b/static/partials/chatroom.html
@@ -1,5 +1,5 @@
-
+