diff --git a/services/client/package.json b/services/client/package.json index 3656a4540..80f602387 100644 --- a/services/client/package.json +++ b/services/client/package.json @@ -11,6 +11,7 @@ "compression": "^1.0.3", "cors": "^2.5.2", "helmet": "^1.3.0", + "i18n": "^0.8.3", "loopback": "^2.38.0", "loopback-boot": "^2.6.5", "loopback-component-explorer": "^2.7.0", diff --git a/services/client/server/i18n/en.json b/services/client/server/i18n/en.json new file mode 100644 index 000000000..a62e31b81 --- /dev/null +++ b/services/client/server/i18n/en.json @@ -0,0 +1,3 @@ +{ + "Hello": "Hello english" +} \ No newline at end of file diff --git a/services/client/server/i18n/es.json b/services/client/server/i18n/es.json new file mode 100644 index 000000000..0ef9e258e --- /dev/null +++ b/services/client/server/i18n/es.json @@ -0,0 +1,3 @@ +{ + "Hello": "Hola espaƱol" +} diff --git a/services/client/server/server.js b/services/client/server/server.js index ef738abce..57dea83a6 100644 --- a/services/client/server/server.js +++ b/services/client/server/server.js @@ -5,6 +5,20 @@ var boot = require('loopback-boot'); var app = module.exports = loopback(); +/*i18n*/ +var i18n = require("i18n"); +i18n.configure({ + directory: __dirname + '/i18n', + defaultLocale: "es" +}); + +/* Prueba i18n */ +app.get('/prueba', function (req,res){ + i18n.setLocale(req.get('Accept-Language').substring(0,2)); + res.send(i18n.__("Hello")); +}); + + app.start = function() { // start the web server return app.listen(function() {