i18n enable runtime node files

This commit is contained in:
Nick O'Leary
2015-04-25 23:29:53 +01:00
parent 7d41781fb4
commit 6d4c64fcd5
9 changed files with 196 additions and 32 deletions

View File

@@ -1,5 +1,5 @@
/**
* Copyright 2013, 2014 IBM Corp.
* Copyright 2013, 2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,12 +32,12 @@ module.exports = function(RED) {
if (this.repeat && !isNaN(this.repeat) && this.repeat > 0) {
this.repeat = this.repeat * 1000;
if (RED.settings.verbose) { this.log("repeat = "+this.repeat); }
if (RED.settings.verbose) { this.log(RED._("inject.repeat",this)); }
this.interval_id = setInterval( function() {
node.emit("input",{});
}, this.repeat );
} else if (this.crontab) {
if (RED.settings.verbose) { this.log("crontab = "+this.crontab); }
if (RED.settings.verbose) { this.log(RED._("inject.crontab",this)); }
this.cronjob = new cron.CronJob(this.crontab,
function() {
node.emit("input",{});
@@ -68,10 +68,10 @@ module.exports = function(RED) {
InjectNode.prototype.close = function() {
if (this.interval_id != null) {
clearInterval(this.interval_id);
if (RED.settings.verbose) { this.log("inject: repeat stopped"); }
if (RED.settings.verbose) { this.log(RED._("inject.stopped")); }
} else if (this.cronjob != null) {
this.cronjob.stop();
if (RED.settings.verbose) { this.log("inject: cronjob stopped"); }
if (RED.settings.verbose) { this.log(RED._("inject.stopped")); }
delete this.cronjob;
}
}
@@ -84,7 +84,7 @@ module.exports = function(RED) {
res.send(200);
} catch(err) {
res.send(500);
node.error("Inject failed:"+err);
node.error(RED._("inject.failed",{error:err}));
}
} else {
res.send(404);

View File

@@ -0,0 +1,8 @@
{
"inject": {
"repeat": "repeat = __repeat__",
"crontab": "crontab = __crontab__",
"stopped": "stopped",
"failed": "Inject failed: __error__"
}
}