diff --git a/red/api/flows.js b/red/api/flows.js index 6b93fce90..1504c0f43 100644 --- a/red/api/flows.js +++ b/red/api/flows.js @@ -13,10 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -var express = require('express'); -var fs = require("fs"); -var events = require("../events"); -var path = require("path"); var log = require("../log"); var redNodes = require("../nodes"); diff --git a/red/api/index.js b/red/api/index.js index 0a0362aff..e9e51bdf5 100644 --- a/red/api/index.js +++ b/red/api/index.js @@ -25,6 +25,7 @@ var flows = require("./flows"); var library = require("./library"); var info = require("./info"); var theme = require("./theme"); +var locales = require("./locales"); var auth = require("./auth"); var needsPermission = auth.needsPermission; @@ -85,6 +86,8 @@ function init(adminApp,storage) { adminApp.get("/nodes/:mod/:set",needsPermission("nodes.read"),nodes.getSet); adminApp.put("/nodes/:mod/:set",needsPermission("nodes.write"),nodes.putSet); + adminApp.get(/^\/locales\/(.+?)\/(.*)$/,needsPermission("nodes.read"),locales.get); + // Library library.init(adminApp); adminApp.post(new RegExp("/library/flows\/(.*)"),needsPermission("library.write"),library.post); diff --git a/red/api/locales.js b/red/api/locales.js new file mode 100644 index 000000000..3649e3f66 --- /dev/null +++ b/red/api/locales.js @@ -0,0 +1,29 @@ +/** + * Copyright 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + **/ +var i18n = require("../i18n"); + +module.exports = { + get: function(req,res) { + var lang = req.params[0]; + var namespace = req.params[1]; + var catalog = i18n.catalog(namespace,lang); + if (catalog) { + res.json(catalog); + } else { + res.send(404); + } + } +} diff --git a/red/api/nodes.js b/red/api/nodes.js index 0cd141947..bed72fc8a 100644 --- a/red/api/nodes.js +++ b/red/api/nodes.js @@ -13,12 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. **/ -var express = require('express'); -var fs = require("fs"); -var path = require("path"); -var when = require('when'); - -var events = require("../events"); var redNodes = require("../nodes"); var comms = require("../comms"); var server = require("../server"); diff --git a/test/red/api/locales_spec.js b/test/red/api/locales_spec.js new file mode 100644 index 000000000..e69de29bb