mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Make PresenceLabel more easily translatable
Signed-off-by: Stefan Parviainen <pafcu@iki.fi>
This commit is contained in:
parent
02629d13d9
commit
df921438f3
@ -44,6 +44,8 @@ module.exports = React.createClass({
|
||||
};
|
||||
},
|
||||
|
||||
// Return duration as a sting 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 (
|
||||
<div className="mx_PresenceLabel">
|
||||
{ this.getPrettyPresence(this.props.presenceState) } { ago }
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<div className="mx_PresenceLabel">
|
||||
{ this.getPrettyPresence(this.props.presenceState) }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="mx_PresenceLabel">
|
||||
{ this.getPrettyPresence(this.props.presenceState, this.props.activeAgo, this.props.currentlyActive) }
|
||||
</div>
|
||||
);
|
||||
},
|
||||
});
|
||||
|
@ -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 <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.",
|
||||
"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",
|
||||
|
Loading…
Reference in New Issue
Block a user