@igea/oac_frontend 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/index.js +21 -0
- package/src/locales/en.json +3 -0
- package/src/locales/it.json +3 -0
- package/src/views/base.twig +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igea/oac_frontend",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Frontend service for the OAC project",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"axios": "1.10.0",
|
|
24
24
|
"express": "5.1.0",
|
|
25
25
|
"get-port": "7.1.0",
|
|
26
|
+
"i18n": "^0.15.1",
|
|
26
27
|
"twig": "1.17.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
package/src/index.js
CHANGED
|
@@ -3,17 +3,38 @@ const express = require("express");
|
|
|
3
3
|
const axios = require("axios");
|
|
4
4
|
const getPort = require('get-port');
|
|
5
5
|
const path = require("path");
|
|
6
|
+
const i18n = require('i18n');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
i18n.configure({
|
|
10
|
+
locales: ['en', 'it'],
|
|
11
|
+
defaultLocale: 'it',
|
|
12
|
+
directory: path.join(__dirname, 'locales'),
|
|
13
|
+
queryParameter: 'lang',
|
|
14
|
+
autoReload: true,
|
|
15
|
+
updateFiles: false, // don't auto-create keys
|
|
16
|
+
api: {
|
|
17
|
+
'__': 't'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
6
21
|
const serviceName = "frontend"
|
|
7
22
|
|
|
8
23
|
const app = express();
|
|
9
24
|
let newPort = null
|
|
10
25
|
|
|
26
|
+
app.use(i18n.init);
|
|
11
27
|
app.use(`/${serviceName}`, express.static(path.join(__dirname, 'public')));
|
|
12
28
|
app.use(express.json());
|
|
13
29
|
|
|
14
30
|
app.set('view engine', 'twig');
|
|
15
31
|
app.set('views', path.join(__dirname, 'views'));
|
|
16
32
|
|
|
33
|
+
app.use((req, res, next) => {
|
|
34
|
+
res.locals.t = req.t;
|
|
35
|
+
next();
|
|
36
|
+
});
|
|
37
|
+
|
|
17
38
|
const register = async function(){
|
|
18
39
|
try {
|
|
19
40
|
console.log(`Registering ${serviceName}...`);
|