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

Add locales api endpoint

This commit is contained in:
Nick O'Leary 2015-04-26 21:28:16 +01:00
parent 6d4c64fcd5
commit b2caba593f
5 changed files with 32 additions and 10 deletions

View File

@ -13,10 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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 log = require("../log");
var redNodes = require("../nodes"); var redNodes = require("../nodes");

View File

@ -25,6 +25,7 @@ var flows = require("./flows");
var library = require("./library"); var library = require("./library");
var info = require("./info"); var info = require("./info");
var theme = require("./theme"); var theme = require("./theme");
var locales = require("./locales");
var auth = require("./auth"); var auth = require("./auth");
var needsPermission = auth.needsPermission; var needsPermission = auth.needsPermission;
@ -85,6 +86,8 @@ function init(adminApp,storage) {
adminApp.get("/nodes/:mod/:set",needsPermission("nodes.read"),nodes.getSet); adminApp.get("/nodes/:mod/:set",needsPermission("nodes.read"),nodes.getSet);
adminApp.put("/nodes/:mod/:set",needsPermission("nodes.write"),nodes.putSet); adminApp.put("/nodes/:mod/:set",needsPermission("nodes.write"),nodes.putSet);
adminApp.get(/^\/locales\/(.+?)\/(.*)$/,needsPermission("nodes.read"),locales.get);
// Library // Library
library.init(adminApp); library.init(adminApp);
adminApp.post(new RegExp("/library/flows\/(.*)"),needsPermission("library.write"),library.post); adminApp.post(new RegExp("/library/flows\/(.*)"),needsPermission("library.write"),library.post);

29
red/api/locales.js Normal file
View File

@ -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);
}
}
}

View File

@ -13,12 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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 redNodes = require("../nodes");
var comms = require("../comms"); var comms = require("../comms");
var server = require("../server"); var server = require("../server");

View File