From 62490834318c6a83cc6632a4320ab75fb2f70354 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Fri, 8 May 2015 14:21:01 +0100 Subject: [PATCH] Extract all core runtime messages --- locales/en-US/runtime.json | 64 +++++++++++++++++++++++++++--- red/api/flows.js | 3 +- red/api/library.js | 9 +++-- red/api/nodes.js | 4 +- red/comms.js | 8 ++-- red/log.js | 4 ++ red/nodes/credentials.js | 5 ++- red/nodes/flows.js | 25 ++++++------ red/nodes/registry/loader.js | 2 +- red/red.js | 3 -- red/server.js | 44 ++++++++++---------- red/storage/localfilesystem.js | 10 ++--- test/red/nodes/credentials_spec.js | 6 +-- 13 files changed, 123 insertions(+), 64 deletions(-) diff --git a/locales/en-US/runtime.json b/locales/en-US/runtime.json index 5164883aa..72e7e3b44 100644 --- a/locales/en-US/runtime.json +++ b/locales/en-US/runtime.json @@ -6,8 +6,8 @@ "settings": "Settings file : __path__" } }, - - "nodes": { + + "server": { "loading": "Loading palette nodes", "errors": "Failed to register __count__ node type", "errors_plural": "Failed to register __count__ node types", @@ -28,10 +28,64 @@ "uninstall-failed": "Uninstall failed", "uninstall-failed-long": "Uninstall of module __name__ failed:", "uninstalled": "Uninstalled module: __name__" - - + } + }, + + "api": { + "flows": { + "error-save": "Error saving flows: __message__" + }, + "library": { + "error-load-entry": "Error loading library entry '__path__': __message__", + "error-save-entry": "Error saving library entry '__path__': __message__", + "error-load-flow": "Error loading flow '__path__': __message__", + "error-save-flow": "Error saving flow '__path__': __message__" + }, + "nodes": { + "enabled": "Enabled node types:", + "disabled": "Disabled node types:", + "error-enable": "Failed to enable node:" + } + }, + + "comms": { + "error": "Communication channel error: __message__", + "error-server": "Communication server error: __message__", + "error-send": "Communication send error: __message__" + }, + + "nodes": { + "credentials": { + "error":"Error loading credentials: __message__", + "not-registered": "Credential type '__type__' is not registered" + }, + "flows": { + "registered-missing": "Missing type registered: __type__", + "error": "Error loading flows: __message__", + "starting-modified-nodes": "Starting modified nodes", + "starting-modified-flows": "Starting modified flows", + "starting-flows": "Starting flows", + "started-modified-nodes": "Started modified nodes", + "started-modified-flows": "Started modified flows", + "started-flows": "Started flows", + "stopping-modified-nodes": "Stopping modified nodes", + "stopping-modified-flows": "Stopping modified flows", + "stopping-flows": "Stopping flows", + "stopped-modified-nodes": "Stopped modified nodes", + "stopped-modified-flows": "Stopped modified flows", + "stopped-flows": "Stopped flows", + "stopped": "Stopped", + "missing-types": "Waiting for missing types to be registered:" } - } + }, + "storage": { + "localfilesystem": { + "user-dir": "User directory : __path__", + "flows-file": "Flows file : __path__", + "create": "Creating new flow file" + } + } + } diff --git a/red/api/flows.js b/red/api/flows.js index 1504c0f43..313cd02fc 100644 --- a/red/api/flows.js +++ b/red/api/flows.js @@ -15,6 +15,7 @@ **/ var log = require("../log"); + var redNodes = require("../nodes"); var settings = require("../settings"); @@ -30,7 +31,7 @@ module.exports = { redNodes.setFlows(flows,deploymentType).then(function() { res.send(204); }).otherwise(function(err) { - log.warn("Error saving flows : "+err.message); + log.warn(log._("api.flows.error-save",{message:err.message})); log.warn(err.stack); res.json(500,{error:"unexpected_error", message:err.message}); }); diff --git a/red/api/library.js b/red/api/library.js index 1d0a2becf..e03f4bd56 100644 --- a/red/api/library.js +++ b/red/api/library.js @@ -17,6 +17,7 @@ var redApp = null; var storage = require("../storage"); var log = require("../log"); + var needsPermission = require("./auth").needsPermission; function createLibrary(type) { @@ -34,7 +35,7 @@ function createLibrary(type) { } }).otherwise(function(err) { if (err) { - log.warn("Error loading library entry '"+path+"' : "+err); + log.warn(log._("api.library.error-load-entry",{path:path,message:err})); if (err.message.indexOf('forbidden') === 0) { log.audit({event: "library.get",type:type,error:"forbidden"},req); res.send(403); @@ -56,7 +57,7 @@ function createLibrary(type) { log.audit({event: "library.set",type:type},req); res.send(204); }).otherwise(function(err) { - log.warn("Error saving library entry '"+path+"' : "+err); + log.warn(log._("api.library.error-save-entry",{path:path,message:err})); if (err.message.indexOf('forbidden') === 0) { log.audit({event: "library.set",type:type,error:"forbidden"},req); res.send(403); @@ -88,7 +89,7 @@ module.exports = { res.send(data); }).otherwise(function(err) { if (err) { - log.warn("Error loading flow '"+req.params[0]+"' : "+err); + log.warn(log._("api.library.error-load-flow",{path:req.params[0],message:err})); if (err.message.indexOf('forbidden') === 0) { log.audit({event: "library.get",type:"flow",path:req.params[0],error:"forbidden"},req); res.send(403); @@ -105,7 +106,7 @@ module.exports = { log.audit({event: "library.set",type:"flow",path:req.params[0]},req); res.send(204); }).otherwise(function(err) { - log.warn("Error loading flow '"+req.params[0]+"' : "+err); + log.warn(log._("api.library.error-save-flow",{path:req.params[0],message:err})); if (err.message.indexOf('forbidden') === 0) { log.audit({event: "library.set",type:"flow",path:req.params[0],error:"forbidden"},req); res.send(403); diff --git a/red/api/nodes.js b/red/api/nodes.js index bed72fc8a..a71bc4413 100644 --- a/red/api/nodes.js +++ b/red/api/nodes.js @@ -226,12 +226,12 @@ function putNode(node, enabled) { return promise.then(function(info) { if (info.enabled === enabled && !info.err) { comms.publish("node/"+(enabled?"enabled":"disabled"),info,false); - log.info(" "+(enabled?"Enabled":"Disabled")+" node types:"); + log.info(" "+log._("api.nodes."+(enabled?"enabled":"disabled"))); for (var i=0;i 0) { - log.info("Waiting for missing types to be registered:"); + log.info(log._("nodes.flows.missing-types")); var knownUnknowns = 0; for (var i=0;i 0) { - log.warn(i18n._("nodes.missing-modules")); + log.warn(log._("server.missing-modules")); var missingModules = {}; for (i=0;i 0) { - log.info(i18n._("nodes.added-types")); + log.info(log._("server.added-types")); for (var i=0;i