UNPKG

acha-framework

Version:

is a modular framework on both client (angular.js) and server (node.js) side, it provides security, orm, ioc, obfuscation and ...

33 lines 1.15 kB
(function (undefined) { Ioc.define('backend.controllers.i18n', [ 'backend.configuration', 'backend.operationResult' ], function (provide, config, OperationResult) { provide({ install: function (app) { app.get('/:lang/i18n', function (req, res) { const language = res.locals.lang; const jsonFile = PATH.join(config.rootDirectory, 'locals', language + '.json'); FSX.readJson(jsonFile, function (err, json) { if (err) { json = {}; } const content = 'window.achasoft.i18n = ' + JSON.stringify(json) + ';'; res.setHeader('content-type', 'text/javascript; charset=utf-8'); res.end(content); }); }); app.get('/api/v1/i18n', function (req, res) { var language = res.locals.lang; var jsonFile = PATH.join(config.rootDirectory, 'locals', language + '.json'); FSX.readJson(jsonFile, function (err, json) { if (err) { json = {}; } res.json(OperationResult.success(json)); }); }); } }); }); }());