Merge remote-tracking branch 'origin/develop' into develop

pull/21833/head
Weblate 2017-11-22 17:17:56 +00:00
commit d2061d7fa1
2 changed files with 35 additions and 31 deletions

View File

@ -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) { getDuration: function(time) {
if (!time) return; if (!time) return;
const t = parseInt(time / 1000); const t = parseInt(time / 1000);
@ -53,41 +55,39 @@ module.exports = React.createClass({
const d = parseInt(t / (60 * 60 * 24)); const d = parseInt(t / (60 * 60 * 24));
if (t < 60) { if (t < 60) {
if (t < 0) { 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) { if (t < 60 * 60) {
return _t("for %(amount)sm", {amount: m}); return _t("%(duration)sm", {duration: m});
} }
if (t < 24 * 60 * 60) { 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) { 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 === "online") return _t("Online");
if (presence === "unavailable") return _t("Idle"); // XXX: is this actually right? if (presence === "unavailable") return _t("Idle"); // XXX: is this actually right?
if (presence === "offline") return _t("Offline"); if (presence === "offline") return _t("Offline");
return _t("Unknown"); return _t("Unknown");
}
}, },
render: function() { render: function() {
if (this.props.activeAgo >= 0) {
const duration = this.getDuration(this.props.activeAgo);
const ago = this.props.currentlyActive || !duration ? "" : duration;
return ( return (
<div className="mx_PresenceLabel"> <div className="mx_PresenceLabel">
{ this.getPrettyPresence(this.props.presenceState) } { ago } { this.getPrettyPresence(this.props.presenceState, this.props.activeAgo, this.props.currentlyActive) }
</div> </div>
); );
} else {
return (
<div className="mx_PresenceLabel">
{ this.getPrettyPresence(this.props.presenceState) }
</div>
);
}
}, },
}); });

View File

@ -227,8 +227,6 @@
"Delete": "Delete", "Delete": "Delete",
"Disable Notifications": "Disable Notifications", "Disable Notifications": "Disable Notifications",
"Enable Notifications": "Enable 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", "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.", "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", "Add a widget": "Add a widget",
@ -321,10 +319,14 @@
"No pinned messages.": "No pinned messages.", "No pinned messages.": "No pinned messages.",
"Loading...": "Loading...", "Loading...": "Loading...",
"Pinned Messages": "Pinned Messages", "Pinned Messages": "Pinned Messages",
"for %(amount)ss": "for %(amount)ss", "%(duration)ss": "%(duration)ss",
"for %(amount)sm": "for %(amount)sm", "%(duration)sm": "%(duration)sm",
"for %(amount)sh": "for %(amount)sh", "%(duration)sh": "%(duration)sh",
"for %(amount)sd": "for %(amount)sd", "%(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", "Online": "Online",
"Idle": "Idle", "Idle": "Idle",
"Offline": "Offline", "Offline": "Offline",
@ -456,6 +458,8 @@
"New community ID (e.g. +foo:%(localDomain)s)": "New community ID (e.g. +foo:%(localDomain)s)", "New community ID (e.g. +foo:%(localDomain)s)": "New community ID (e.g. +foo:%(localDomain)s)",
"You have <a>enabled</a> URL previews by default.": "You have <a>enabled</a> URL previews by default.", "You have <a>enabled</a> URL previews by default.": "You have <a>enabled</a> URL previews by default.",
"You have <a>disabled</a> URL previews by default.": "You have <a>disabled</a> URL previews by default.", "You have <a>disabled</a> URL previews by default.": "You have <a>disabled</a> 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", "URL Previews": "URL Previews",
"Error decrypting audio": "Error decrypting audio", "Error decrypting audio": "Error decrypting audio",
"Error decrypting attachment": "Error decrypting attachment", "Error decrypting attachment": "Error decrypting attachment",