mirror of
https://github.com/node-red/node-red-nodes.git
synced 2025-03-01 10:37:43 +00:00
Add i18n content for moved core nodes
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
<script type="text/x-red" data-template-name="e-mail">
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-envelope"></i> To</label>
|
||||
<label for="node-input-name"><i class="fa fa-envelope"></i> <span data-i18n="email.label.to"></span></label>
|
||||
<input type="text" id="node-input-name" placeholder="email@address.com">
|
||||
</div>
|
||||
<!-- <div class="form-row">
|
||||
@@ -45,27 +45,27 @@
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="form-row">
|
||||
<label for="node-input-server"><i class="fa fa-globe"></i> Server</label>
|
||||
<label for="node-input-server"><i class="fa fa-globe"></i> <span data-i18n="email.label.server"></span></label>
|
||||
<input type="text" id="node-input-server" placeholder="smtp.gmail.com">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-port"><i class="fa fa-random"></i> Port</label>
|
||||
<label for="node-input-port"><i class="fa fa-random"></i> <span data-i18n="email.label.port"></span></label>
|
||||
<input type="text" id="node-input-port" placeholder="465">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-userid"><i class="fa fa-user"></i> Userid</label>
|
||||
<label for="node-input-userid"><i class="fa fa-user"></i> <span data-i18n="email.label.userid"></span></label>
|
||||
<input type="text" id="node-input-userid">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-password"><i class="fa fa-lock"></i> Password</label>
|
||||
<label for="node-input-password"><i class="fa fa-lock"></i> <span data-i18n="email.label.password"></span></label>
|
||||
<input type="password" id="node-input-password">
|
||||
</div>
|
||||
<br/>
|
||||
<div class="form-row">
|
||||
<label for="node-input-dname"><i class="fa fa-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-dname" placeholder="Name">
|
||||
<label for="node-input-dname"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||
<input type="text" id="node-input-dname" data-i18n="[placeholder]common.label.name">
|
||||
</div>
|
||||
<div class="form-tips" id="node-tip"><b>Note:</b> Copied credentials from global emailkeys.js file.</div>
|
||||
<div class="form-tips" id="node-tip"><span data-i18n="[html]email.tip.cred"></span></div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="e-mail">
|
||||
@@ -110,7 +110,7 @@
|
||||
$('#node-tip').show();
|
||||
} else {
|
||||
$('#node-tip').hide();
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -119,36 +119,36 @@
|
||||
|
||||
<script type="text/x-red" data-template-name="e-mail in">
|
||||
<div class="form-row node-input-repeat">
|
||||
<label for="node-input-repeat"><i class="fa fa-repeat"></i> Check Repeat (S)</label>
|
||||
<input type="text" id="node-input-repeat" placeholder="300">
|
||||
<label for="node-input-repeat"><i class="fa fa-repeat"></i> <span data-i18n="email.label.repeat"></span></label>
|
||||
<input type="text" id="node-input-repeat" style="width: 80px"> <span data-i18n="email.label.seconds">seconds</span>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-server"><i class="fa fa-globe"></i> Server</label>
|
||||
<label for="node-input-server"><i class="fa fa-globe"></i> <span data-i18n="email.label.server"></span></label>
|
||||
<input type="text" id="node-input-server" placeholder="imap.gmail.com">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-port"><i class="fa fa-random"></i> Port</label>
|
||||
<label for="node-input-port"><i class="fa fa-random"></i> <span data-i18n="email.label.port"></span></label>
|
||||
<input type="text" id="node-input-port" placeholder="993">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-userid"><i class="fa fa-user"></i> Userid</label>
|
||||
<label for="node-input-userid"><i class="fa fa-user"></i> <span data-i18n="email.label.userid"></span></label>
|
||||
<input type="text" id="node-input-userid">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-password"><i class="fa fa-lock"></i> Password</label>
|
||||
<label for="node-input-password"><i class="fa fa-lock"></i> <span data-i18n="email.label.password"></span></label>
|
||||
<input type="password" id="node-input-password">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label for="node-input-box"><i class="fa fa-inbox"></i> Folder</label>
|
||||
<label for="node-input-box"><i class="fa fa-inbox"></i> <span data-i18n="email.label.folder"></span></label>
|
||||
<input type="text" id="node-input-box">
|
||||
</div>
|
||||
<br/>
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
|
||||
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">
|
||||
</div>
|
||||
<div class="form-tips" id="node-tip"><b>Note:</b> Copied credentials from global emailkeys.js file.</div>
|
||||
<div id="node-input-tip" class="form-tips">Tip: <b>ONLY</b> retrieves the single most recent email.</div>
|
||||
<div class="form-tips" id="node-tip"><span data-i18n="[html]email.tip.cred"></span></div>
|
||||
<div id="node-input-tip" class="form-tips"><span data-i18n="[html]email.tip.recent"></span></div>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="e-mail in">
|
||||
@@ -192,7 +192,7 @@
|
||||
$('#node-tip').show();
|
||||
} else {
|
||||
$('#node-tip').hide();
|
||||
}
|
||||
};
|
||||
if (typeof this.box === 'undefined') {
|
||||
$("#node-input-box").val("INBOX");
|
||||
this.box = "INBOX";
|
||||
|
@@ -40,7 +40,7 @@ module.exports = function(RED) {
|
||||
this.userid = globalkeys.user;
|
||||
flag = true;
|
||||
} else {
|
||||
this.error("No e-mail userid set");
|
||||
this.error(RED._("email.errors.nouserid"));
|
||||
}
|
||||
}
|
||||
if (this.credentials && this.credentials.hasOwnProperty("password")) {
|
||||
@@ -50,7 +50,7 @@ module.exports = function(RED) {
|
||||
this.password = globalkeys.pass;
|
||||
flag = true;
|
||||
} else {
|
||||
this.error("No e-mail password set");
|
||||
this.error(RED._("email.errors.nopassword"));
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
@@ -71,9 +71,9 @@ module.exports = function(RED) {
|
||||
this.on("input", function(msg) {
|
||||
if (msg.hasOwnProperty("payload")) {
|
||||
if (smtpTransport) {
|
||||
node.status({fill:"blue",shape:"dot",text:"sending"});
|
||||
node.status({fill:"blue",shape:"dot",text:RED._("email.status.sending")});
|
||||
if (msg.to && node.name && (msg.to !== node.name)) {
|
||||
node.warn("Warning: msg properties can no longer override set node properties. See bit.ly/nr-override-msg-props");
|
||||
node.warn(RED._("common.errors.nooverride"));
|
||||
}
|
||||
var sendopts = { from: node.userid }; // sender address
|
||||
sendopts.to = node.name || msg.to; // comma separated list of addressees
|
||||
@@ -92,27 +92,27 @@ module.exports = function(RED) {
|
||||
sendopts.attachments[0].contentType = msg.headers["content-type"];
|
||||
}
|
||||
// Create some body text..
|
||||
sendopts.text = "Your file from Node-RED is attached : "+(msg.filename.replace(/^.*[\\\/]/, '') || "file.bin")+ (msg.hasOwnProperty("description") ? "\n\n"+msg.description : "");
|
||||
sendopts.text = RED._("email.default-message",{filename:(msg.filename.replace(/^.*[\\\/]/, '') || "file.bin"),description:(msg.hasOwnProperty("description") ? "\n\n"+msg.description : "")});
|
||||
}
|
||||
else {
|
||||
var payload = RED.util.ensureString(msg.payload);
|
||||
sendopts.text = payload; // plaintext body
|
||||
sendopts.text = payload; // plaintext body
|
||||
if (/<[a-z][\s\S]*>/i.test(payload)) { sendopts.html = payload; } // html body
|
||||
if (msg.attachments) { sendopts.attachments = msg.attachments; } // add attachments
|
||||
}
|
||||
smtpTransport.sendMail(sendopts, function(error, info) {
|
||||
if (error) {
|
||||
node.error(error,msg);
|
||||
node.status({fill:"red",shape:"ring",text:"send failed"});
|
||||
node.status({fill:"red",shape:"ring",text:RED._("email.status.sendfail")});
|
||||
} else {
|
||||
node.log("Message sent: " + info.response);
|
||||
node.log(RED._("email.status.messagesent",{response:info.response}));
|
||||
node.status({});
|
||||
}
|
||||
});
|
||||
}
|
||||
else { node.warn("No Email credentials found. See info panel."); }
|
||||
else { node.warn(RED._("email.errors.nocredentials")); }
|
||||
}
|
||||
else { node.warn("No payload to send"); }
|
||||
else { node.warn(RED._("email.errors.nopayload")); }
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("e-mail",EmailNode,{
|
||||
@@ -139,7 +139,7 @@ module.exports = function(RED) {
|
||||
this.userid = globalkeys.user;
|
||||
flag = true;
|
||||
} else {
|
||||
this.error("No e-mail userid set");
|
||||
this.error(RED._("email.errors.nouserid"));
|
||||
}
|
||||
}
|
||||
if (this.credentials && this.credentials.hasOwnProperty("password")) {
|
||||
@@ -149,7 +149,7 @@ module.exports = function(RED) {
|
||||
this.password = globalkeys.pass;
|
||||
flag = true;
|
||||
} else {
|
||||
this.error("No e-mail password set");
|
||||
this.error(RED._("email.errors.nopassword"));
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
@@ -172,7 +172,6 @@ module.exports = function(RED) {
|
||||
});
|
||||
|
||||
if (!isNaN(this.repeat) && this.repeat > 0) {
|
||||
node.log("repeat = "+this.repeat);
|
||||
this.interval_id = setInterval( function() {
|
||||
node.emit("input",{});
|
||||
}, this.repeat );
|
||||
@@ -180,19 +179,19 @@ module.exports = function(RED) {
|
||||
|
||||
this.on("input", function(msg) {
|
||||
imap.once('ready', function() {
|
||||
node.status({fill:"blue",shape:"dot",text:"fetching"});
|
||||
node.status({fill:"blue",shape:"dot",text:RED._("email.status.fetching")});
|
||||
var pay = {};
|
||||
imap.openBox(node.box, false, function(err, box) {
|
||||
if (err) {
|
||||
node.status({fill:"red",shape:"ring",text:"fetch folder error"});
|
||||
node.error("Failed to fetch folder "+node.box,err);
|
||||
node.status({fill:"red",shape:"ring",text:RED._("email.status.foldererror")});
|
||||
node.error(RED._("email.errors.fetchfail",{folder:node.box}),err);
|
||||
}
|
||||
else {
|
||||
if (box.messages.total > 0) {
|
||||
//var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER.FIELDS (FROM SUBJECT DATE TO CC BCC)','TEXT'] });
|
||||
var f = imap.seq.fetch(box.messages.total + ':*', { markSeen:true, bodies: ['HEADER','TEXT'] });
|
||||
f.on('message', function(msg, seqno) {
|
||||
node.log('message: #'+ seqno);
|
||||
node.log(RED._("email.status.message",{number:seqno}));
|
||||
var prefix = '(#' + seqno + ') ';
|
||||
msg.on('body', function(stream, info) {
|
||||
var buffer = '';
|
||||
@@ -210,62 +209,54 @@ module.exports = function(RED) {
|
||||
var parts = buffer.split("Content-Type");
|
||||
for (var p = 0; p < parts.length; p++) {
|
||||
if (parts[p].indexOf("text/plain") >= 0) {
|
||||
console.log("TEXT");
|
||||
pay.payload = parts[p].split("\n").slice(1,-2).join("\n").trim();
|
||||
}
|
||||
else if (parts[p].indexOf("text/html") >= 0) {
|
||||
console.log("HTML");
|
||||
pay.html = parts[p].split("\n").slice(1,-2).join("\n").trim();
|
||||
} else {
|
||||
console.log("OTHER");
|
||||
pay.payload = parts[0];
|
||||
}
|
||||
console.log("***",pay.payload,"***");
|
||||
}
|
||||
//pay.body = buffer;
|
||||
}
|
||||
});
|
||||
});
|
||||
msg.on('end', function() {
|
||||
//node.log('Finished: '+prefix);
|
||||
//node.log('finished: '+prefix);
|
||||
});
|
||||
});
|
||||
f.on('error', function(err) {
|
||||
node.warn('fetch message error: ' + err);
|
||||
node.status({fill:"red",shape:"ring",text:"fetch message error"});
|
||||
node.warn(RED._("email.errors.messageerror",{error:err}));
|
||||
node.status({fill:"red",shape:"ring",text:RED._("email.status.messageerror")});
|
||||
});
|
||||
f.on('end', function() {
|
||||
delete(pay._msgid);
|
||||
if (JSON.stringify(pay) !== oldmail) {
|
||||
oldmail = JSON.stringify(pay);
|
||||
node.send(pay);
|
||||
node.log('received new email: '+pay.topic);
|
||||
node.log(RED._("email.status.newemail",{topic:pay.topic}));
|
||||
}
|
||||
else { node.log('duplicate not sent: '+pay.topic); }
|
||||
//node.status({fill:"green",shape:"dot",text:"ok"});
|
||||
else { node.log(RED._("email.status.duplicate",{topic:pay.topic})); }
|
||||
//node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")});
|
||||
node.status({});
|
||||
});
|
||||
}
|
||||
else {
|
||||
node.log("you have achieved inbox zero");
|
||||
//node.status({fill:"green",shape:"dot",text:"ok"});
|
||||
node.log(RED._("email.status.inboxzero"));
|
||||
//node.status({fill:"green",shape:"dot",text:RED._("common.status.ok")});
|
||||
node.status({});
|
||||
}
|
||||
}
|
||||
imap.end();
|
||||
});
|
||||
});
|
||||
node.status({fill:"grey",shape:"dot",text:"connecting"});
|
||||
node.status({fill:"grey",shape:"dot",text:RED._("common.status.connecting")});
|
||||
imap.connect();
|
||||
});
|
||||
|
||||
imap.on('error', function(err) {
|
||||
node.log(err);
|
||||
node.status({fill:"red",shape:"ring",text:"connect error"});
|
||||
});
|
||||
|
||||
this.on("error", function(err) {
|
||||
node.log("error: ",err);
|
||||
node.status({fill:"red",shape:"ring",text:RED._("email.status.connecterror")});
|
||||
});
|
||||
|
||||
this.on("close", function() {
|
||||
|
43
social/email/locales/en-US/61-email.json
Normal file
43
social/email/locales/en-US/61-email.json
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"email": {
|
||||
"label": {
|
||||
"to": "To",
|
||||
"server": "Server",
|
||||
"port": "Port",
|
||||
"userid": "Userid",
|
||||
"password": "Password",
|
||||
"repeat": "Refresh",
|
||||
"seconds": "seconds",
|
||||
"folder": "Folder"
|
||||
},
|
||||
|
||||
"default-message": "Your file from Node-RED is attached: __filename__ __description__",
|
||||
|
||||
|
||||
"tip": {
|
||||
"cred": "<b>Note:</b> Copied credentials from global emailkeys.js file.",
|
||||
"recent": "Tip: Only retrieves the single most recent email."
|
||||
},
|
||||
"status": {
|
||||
"messagesent": "Message sent: __response__",
|
||||
"fetching": "fetching",
|
||||
"foldererror": "fetch folder error",
|
||||
"messageerror": "fetch message error",
|
||||
"message": "message #__number__",
|
||||
"newemail": "received new email: __topic__",
|
||||
"duplicate": "duplicate not sent: __topic__",
|
||||
"inboxzero": "you have achieved Inbox Zero",
|
||||
"sending": "sending",
|
||||
"sendfail": "send failed",
|
||||
"connecterror": "connect error"
|
||||
},
|
||||
"errors": {
|
||||
"nouserid": "No e-mail userid set",
|
||||
"nopassword": "No e-mail password set",
|
||||
"nocredentials": "No Email credentials found. See info panel.",
|
||||
"nopayload": "No payload to send",
|
||||
"fetchfail": "Failed to fetch folder: __folder__",
|
||||
"messageerror": "Fetch message error: __error__"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user