1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

locale exposed to editor

This commit is contained in:
Allen Boone 2015-05-28 15:17:31 -04:00 committed by Nick O'Leary
parent 2563649b3e
commit e6ed8ee509
5 changed files with 27 additions and 237 deletions

2
.gitignore vendored
View File

@ -15,3 +15,5 @@ flows*.json
nodes/node-red-nodes/ nodes/node-red-nodes/
node_modules node_modules
public public
locales/zz-ZZ
nodes/core/locales/zz-ZZ

View File

@ -1,142 +0,0 @@
{
"workspace": {
"label": {
"name": "[G'Nameฏูİı]"
}
},
"menu": {
"label": {
"sidebar": "[G'Sidebarฏูİı]",
"displayStatus": "[G'y node statusฏูİı]",
"import": "[G'Importฏูİı]",
"export": "[G'Exportฏูİı]",
"clipboard": "[G'Clipboardฏูİı]",
"library": "[G'Libraryฏูİı]",
"configurationNodes": "[G'uration nodesฏูİı]",
"subflows": "[G'Subflowsฏูİı]",
"createSubflow": "[G'te subflowฏูİı]",
"selectionToSubflow": "[G'on to subflowฏูİı]",
"workspaces": "[G'orkspacesฏูİı]",
"add": "[G'Addฏูİı]",
"rename": "[G'Renameฏูİı]",
"delete": "[G'Deleteฏูİı]",
"keyboardShortcuts": "[G'rd Shortcutsฏูİı]",
"login": "[G'Loginฏูİı]",
"logout": "[G'Logoutฏูİı]"
}
},
"notification": {
"nodeAdded": "[G' d to palette:ฏูİı|]",
"nodeAdded_plural": "[G' ed to paletteฏูİı]",
"nodeRemoved": "[G' ed from palette:ฏูİı|]",
"nodeRemoved_plural": "[G' ved from palette:ฏูİı|]",
"nodeEnabled": "[G'e enabled:ฏูİı|]",
"nodeEnabled_plural": "[G's enabled:ฏูİı|]",
"nodeDisabled": "[G' disabled:ฏูİı|]",
"nodeDisabled_plural": "[G's disabled:ฏูİı|]",
"lostConnectionError": "[G'<b></b>: onnection to serverฏูİı]",
"importUnrecognised": "[G' unrecognised ฏูİı|]",
"loggedInAs": "[G'ged in as ฏูİı|]",
"invalidFilename": "[G'id filenameฏูİı]",
"savedType": "[G'd __type__ฏูİı]",
"saveFailed": "[G'e failed: ฏูİı|]",
"noNodesSelected": "[G'<strong> e subflow</strong>: no nodes selectedฏูİı]",
"multipleInputsToSelection": "[G'<strong> subflow</strong>: multiple inputs to selectionฏูİı]",
"cannotAddSubflowToItself": "[G'<strong></strong>: t add subflow to itselfฏูİı]",
"cannotAddCircularReference": "[G'<strong></strong>: dd subflow - circular reference detectedฏูİı]",
"nodeCopied": "[G'____ de copiedฏูİı]",
"nodeCopied_plural": "[G'____ es copiedฏูİı]",
"undeployedChanges": "[G'<strong></strong>: has undeployed changesฏูİı]",
"nodeActionDisabled": "[G'<strong></strong>: actions disabled within subflowฏูİı]",
"error": "[G'<strong>Error</strong>: ฏูİı|]"
},
"error": {
"apiSubflowOnly": "[G' bflow only. called with:ฏูİı|]",
"invalidFlow": "[G'lid flow: ฏูİı|]",
"cannotAddSubflowToItself": "[G' subflow to itselfฏูİı]",
"cannotAddCircularReference": "[G' bflow - circular reference detectedฏูİı]"
},
"dialog": {
"cancel": "[G'Cancelฏูİı]",
"login": "[G'Loginฏูİı]",
"loginFailed": "[G'gin failedฏูİı]",
"ok": "[G'Okฏูİı]",
"delete": "[G'Deleteฏูİı]",
"close": "[G'Closeฏูİı]",
"nodes": "[G' Nodes:ฏูİı|]",
"selectToCopy": "[G' t above and copy to the clipboard with Ctrl-C.ฏูİı|]",
"pasteNodesHere": "[G' nodes hereฏูİı]",
"importNodes": "[G'port nodesฏูİı]",
"exportNodesClipboard": "[G' es to clipboardฏูİı]",
"renameSheet": "[G'name sheetฏูİı]",
"confirmDelete": "[G'irm deleteฏูİı]"
},
"deploy": {
"deploy": "[G'Deployฏูİı]",
"full": "[G'Fullฏูİı]",
"modifiedFlows": "[G'fied Flowsฏูİı]",
"modifiedNodes": "[G'fied Nodesฏูİı]",
"fullDesc": "[G' rything in the workspaceฏูİı]",
"modifiedFlowsDesc": "[G' flows that contain changed nodesฏูİı]",
"modifiedNodesDesc": "[G' s nodes that have changedฏูİı]",
"confirmDeploy": "[G'irm deployฏูİı]",
"cancelDeploy": "[G'Cancelฏูİı]",
"undeployedChanges": "[G' loyed changes.\n\nLeaving this page will lose these changes.ฏูİı|]",
"successfulDeploy": "[G'fully Deployedฏูİı]",
"error": "[G'<strong>Error</strong>: ฏูİı|]",
"noResponseError": "[G' se from serverฏูİı]"
},
"editor": {
"savedNodes": "[G'ved nodesฏูİı]",
"configEdit": "[G'editฏูİı]",
"configAdd": "[G'addฏูİı]",
"configDelete": "[G'Deleteฏูİı]",
"editFlow": "[G'dit flow ฏูİı|]",
"nodesUse": "[G'____ uses this configฏูİı]",
"nodesUse_plural": "[G'____ s use this configฏูİı]",
"addNewConfig": "[G' __e__ config nodeฏูİı]",
"editConfig": "[G' ____ onfig nodeฏูİı]",
"addNewType": "[G' __type__...ฏูİı|]",
"subflow": "[G'Subflow: ฏูİı|]",
"subflowInstances": "[G' __t__ instance of this subflowฏูİı]",
"subflowInstances_plural": "[G' __nt__ instances of this subflowฏูİı]"
},
"keyboard": {
"selectAll": "[G't all nodesฏูİı]",
"selectAllConnected": "[G' connected nodesฏูİı]",
"addRemoveNode": "[G'/ node from selectionฏูİı]",
"deleteSelected": "[G' ected nodes or linkฏูİı]",
"importNode": "[G'port nodesฏูİı]",
"exportNode": "[G' elected nodesฏูİı]",
"toggleSidebar": "[G'le sidebarฏูİı]",
"deleteNode": "[G' ected nodes or linkฏูİı]",
"copyNode": "[G' lected nodesฏูİı]",
"cutNode": "[G' ected nodesฏูİı]",
"pasteNode": "[G'ste nodesฏูİı]"
},
"library": {
"openLibrary": "[G' Library...ฏูİı|]",
"saveToLibrary": "[G' Library...ฏูİı|]",
"typeLibrary": "[G'____ ibraryฏูİı]",
"unnamedType": "[G'ed __type__ฏูİı]",
"saveToLibrary": "[G' to Libraryฏูİı]",
"exportToLibrary": "[G' des to libraryฏูİı]"
},
"palette": {
"noInfo": "[G' ation availableฏูİı]",
"popOverError": "[G' ting pop-over label for '__type__'.ฏูİı|]"
},
"tabInfo": {
"node": "[G'Nodeฏูİı]",
"type": "[G'Typeฏูİı]",
"id": "[G'IDฏูİı]",
"subflow": "[G'Subflowฏูİı]",
"name": "[G'nameฏูİı]",
"instances": "[G'instancesฏูİı]",
"properties": "[G'ropertiesฏูİı]",
"blank": "[G'blankฏูİı]"
},
"workspaces": {
"subflow": "[G'Subflow: ฏูİı|]"
}
}

View File

@ -1,91 +0,0 @@
{
"runtime": {
"welcome": "[G'e to Node-REDฏูİı]",
"version": "[G'____ ersion: __version__ฏูİı]",
"paths": {
"settings": "[G' ile : __path__ฏูİı]"
}
},
"server": {
"loading": "[G' palette nodesฏูİı]",
"errors": "[G' ister __count__ node typeฏูİı]",
"errors_plural": "[G' ister __count__ node typesฏูİı]",
"errors-help": "[G' - for detailsฏูİı]",
"missing-modules": "[G' node modules:ฏูİı|]",
"removing-modules": "[G' odules from configฏูİı]",
"added-types": "[G' node types:ฏูİı|]",
"removed-types": "[G'd node types:ฏูİı|]",
"install": {
"invalid": "[G'd module nameฏูİı]",
"installing": "[G'g module: __name__ฏูİı]",
"installed": "[G' module: __name__ฏูİı]",
"install-failed": "[G'all failedฏูİı]",
"install-failed-long": "[G'n of module __name__ failed:ฏูİı|]",
"install-failed-not-found": "[G'$(-led-long) module not foundฏูİı]",
"uninstalling": "[G'ing module: __name__ฏูİı]",
"uninstall-failed": "[G'tall failedฏูİı]",
"uninstall-failed-long": "[G' f module __name__ failed:ฏูİı|]",
"uninstalled": "[G'ed module: __name__ฏูİı]"
}
},
"api": {
"flows": {
"error-save": "[G' ng flows: __message__ฏูİı]"
},
"library": {
"error-load-entry": "[G' g library entry '__path__': __message__ฏูİı]",
"error-save-entry": "[G' library entry '__path__': __message__ฏูİı]",
"error-load-flow": "[G' g flow '__path__': __message__ฏูİı]",
"error-save-flow": "[G' flow '__path__': __message__ฏูİı]"
},
"nodes": {
"enabled": "[G'd node types:ฏูİı|]",
"disabled": "[G'd node types:ฏูİı|]",
"error-enable": "[G' enable node:ฏูİı|]"
}
},
"comms": {
"error": "[G'on channel error: __message__ฏูİı]",
"error-server": "[G'on server error: __message__ฏูİı]",
"error-send": "[G'ion send error: __message__ฏูİı]"
},
"nodes": {
"credentials": {
"error":"[G' g credentials: __message__ฏูİı]",
"not-registered": "[G' ype '__type__' is not registeredฏูİı]"
},
"flows": {
"registered-missing": "[G' e registered: __type__ฏูİı]",
"error": "[G' ing flows: __message__ฏูİı]",
"starting-modified-nodes": "[G' modified nodesฏูİı]",
"starting-modified-flows": "[G' modified flowsฏูİı]",
"starting-flows": "[G'ting flowsฏูİı]",
"started-modified-nodes": "[G' odified nodesฏูİı]",
"started-modified-flows": "[G' odified flowsฏูİı]",
"started-flows": "[G'rted flowsฏูİı]",
"stopping-modified-nodes": "[G' modified nodesฏูİı]",
"stopping-modified-flows": "[G' modified flowsฏูİı]",
"stopping-flows": "[G'ping flowsฏูİı]",
"stopped-modified-nodes": "[G' odified nodesฏูİı]",
"stopped-modified-flows": "[G' odified flowsฏูİı]",
"stopped-flows": "[G'pped flowsฏูİı]",
"stopped": "[G'Stoppedฏูİı]",
"missing-types": "[G' issing types to be registered:ฏูİı|]"
}
},
"storage": {
"localfilesystem": {
"user-dir": "[G' tory : __path__ฏูİı]",
"flows-file": "[G' le : __path__ฏูİı]",
"create": "[G' new flow fileฏูİı]"
}
}
}

View File

@ -19,8 +19,12 @@ module.exports = {
get: function(req,res) { get: function(req,res) {
var namespace = req.params[0]; var namespace = req.params[0];
namespace = namespace.replace(/\.json$/,""); namespace = namespace.replace(/\.json$/,"");
var lang = req.query["lang"]||"en-US"; // TODO: determine requested lang var lang = i18n.determineLangFromHeaders(req.acceptedLanguages);
var catalog = i18n.catalog(namespace,lang); var prevLang = i18n.i.lng();
res.json(catalog||{}); i18n.i.setLng(lang, function(){
var catalog = i18n.catalog(namespace,lang);
res.json(catalog||{});
});
i18n.i.setLng(prevLang);
} }
} }

View File

@ -101,12 +101,29 @@ function getCatalog(namespace,lang) {
return result; return result;
} }
function determineLangFromHeaders(acceptedLanguages){
var lang = "en-US";
var supportedLanguages = ['en-US', 'es', 'fr', 'it', 'de', 'pt-BR', 'zh', 'zh-TW', 'ko', 'ja', 'zz-ZZ']; // TODO: pull this value from settings
for (var i=0;i<acceptedLanguages.length;i++){
if (supportedLanguages.indexOf(acceptedLanguages[i]) !== -1){
lang = acceptedLanguages[i];
break;
// check the language without the country code
} else if (supportedLanguages.indexOf(acceptedLanguages[i].split("-")[0]) !== -1) {
lang = acceptedLanguages[i].split("-")[0];
break;
}
}
return lang;
}
var obj = module.exports = { var obj = module.exports = {
init: init, init: init,
registerMessageCatalog: registerMessageCatalog, registerMessageCatalog: registerMessageCatalog,
catalog: getCatalog, catalog: getCatalog,
i: i18n i: i18n,
determineLangFromHeaders: determineLangFromHeaders
} }
obj['_'] = function() { obj['_'] = function() {