diff --git a/src/components/views/rooms/PresenceLabel.js b/src/components/views/rooms/PresenceLabel.js index 69ba7c39c3..b6e171100b 100644 --- a/src/components/views/rooms/PresenceLabel.js +++ b/src/components/views/rooms/PresenceLabel.js @@ -44,6 +44,8 @@ module.exports = React.createClass({ }; }, + // Return duration as a string using appropriate time units + // XXX: This would be better handled using a culture-aware library, but we don't use one yet. getDuration: function(time) { if (!time) return; const t = parseInt(time / 1000); @@ -53,41 +55,39 @@ module.exports = React.createClass({ const d = parseInt(t / (60 * 60 * 24)); if (t < 60) { if (t < 0) { - return _t("for %(amount)ss", {amount: 0}); + return _t("%(duration)ss", {duration: 0}); } - return _t("for %(amount)ss", {amount: s}); + return _t("%(duration)ss", {duration: s}); } if (t < 60 * 60) { - return _t("for %(amount)sm", {amount: m}); + return _t("%(duration)sm", {duration: m}); } if (t < 24 * 60 * 60) { - return _t("for %(amount)sh", {amount: h}); + return _t("%(duration)sh", {duration: h}); } - return _t("for %(amount)sd", {amount: d}); + return _t("%(duration)sd", {duration: d}); }, - getPrettyPresence: function(presence) { - if (presence === "online") return _t("Online"); - if (presence === "unavailable") return _t("Idle"); // XXX: is this actually right? - if (presence === "offline") return _t("Offline"); - return _t("Unknown"); + getPrettyPresence: function(presence, activeAgo, currentlyActive) { + if (!currentlyActive && activeAgo !== undefined && activeAgo > 0) { + const duration = this.getDuration(activeAgo); + if (presence === "online") return _t("Online for %(duration)s", { duration: duration }); + if (presence === "unavailable") return _t("Idle for %(duration)s", { duration: duration }); // XXX: is this actually right? + if (presence === "offline") return _t("Offline for %(duration)s", { duration: duration }); + return _t("Unknown for %(duration)s", { duration: duration }); + } else { + if (presence === "online") return _t("Online"); + if (presence === "unavailable") return _t("Idle"); // XXX: is this actually right? + if (presence === "offline") return _t("Offline"); + return _t("Unknown"); + } }, render: function() { - if (this.props.activeAgo >= 0) { - const duration = this.getDuration(this.props.activeAgo); - const ago = this.props.currentlyActive || !duration ? "" : duration; - return ( -
- { this.getPrettyPresence(this.props.presenceState) } { ago } -
- ); - } else { - return ( -
- { this.getPrettyPresence(this.props.presenceState) } -
- ); - } + return ( +
+ { this.getPrettyPresence(this.props.presenceState, this.props.activeAgo, this.props.currentlyActive) } +
+ ); }, }); diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 128a07bc15..93030269ad 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -227,8 +227,6 @@ "Delete": "Delete", "Disable Notifications": "Disable Notifications", "Enable Notifications": "Enable Notifications", - "URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.", - "URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.", "Cannot add any more widgets": "Cannot add any more widgets", "The maximum permitted number of widgets have already been added to this room.": "The maximum permitted number of widgets have already been added to this room.", "Add a widget": "Add a widget", @@ -321,10 +319,14 @@ "No pinned messages.": "No pinned messages.", "Loading...": "Loading...", "Pinned Messages": "Pinned Messages", - "for %(amount)ss": "for %(amount)ss", - "for %(amount)sm": "for %(amount)sm", - "for %(amount)sh": "for %(amount)sh", - "for %(amount)sd": "for %(amount)sd", + "%(duration)ss": "%(duration)ss", + "%(duration)sm": "%(duration)sm", + "%(duration)sh": "%(duration)sh", + "%(duration)sd": "%(duration)sd", + "Online for %(duration)s": "Online for %(duration)s", + "Idle for %(duration)s": "Idle for %(duration)s", + "Offline for %(duration)s": "Offline for %(duration)s", + "Unknown for %(duration)s": "Unknown for %(duration)s", "Online": "Online", "Idle": "Idle", "Offline": "Offline", @@ -456,6 +458,8 @@ "New community ID (e.g. +foo:%(localDomain)s)": "New community ID (e.g. +foo:%(localDomain)s)", "You have enabled URL previews by default.": "You have enabled URL previews by default.", "You have disabled URL previews by default.": "You have disabled URL previews by default.", + "URL previews are enabled by default for participants in this room.": "URL previews are enabled by default for participants in this room.", + "URL previews are disabled by default for participants in this room.": "URL previews are disabled by default for participants in this room.", "URL Previews": "URL Previews", "Error decrypting audio": "Error decrypting audio", "Error decrypting attachment": "Error decrypting attachment",