adapt-authoring-lang 1.2.4 → 1.3.0
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/bin/check.js +4 -2
- package/lib/LangModule.js +6 -21
- package/package.json +2 -2
- package/routes.json +23 -0
package/bin/check.js
CHANGED
|
@@ -52,10 +52,12 @@ async function getTranslatedStrings () {
|
|
|
52
52
|
await Promise.all((langPacks).map(async l => {
|
|
53
53
|
await Promise.all((await fs.readdir(l)).map(async f => {
|
|
54
54
|
const keys = JSON.parse(await fs.readFile(`${l}/${f}`))
|
|
55
|
-
const
|
|
55
|
+
const parts = f.replace(/\.json$/, '').split('.')
|
|
56
|
+
const lang = parts[0]
|
|
57
|
+
const id = parts[1] // undefined for {lang}.json files
|
|
56
58
|
if (!keyMap[lang]) keyMap[lang] = {}
|
|
57
59
|
Object.keys(keys)
|
|
58
|
-
.map(k => `${id}.${k}`)
|
|
60
|
+
.map(k => id ? `${id}.${k}` : k)
|
|
59
61
|
.forEach(k => {
|
|
60
62
|
keyMap[lang][k] = false
|
|
61
63
|
})
|
package/lib/LangModule.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AbstractModule } from 'adapt-authoring-core'
|
|
2
|
-
import
|
|
2
|
+
import { loadRouteConfig, registerRoutes } from 'adapt-authoring-server'
|
|
3
|
+
import fs from 'node:fs/promises'
|
|
3
4
|
import { glob } from 'glob'
|
|
4
|
-
import path from 'path'
|
|
5
|
+
import path from 'node:path'
|
|
5
6
|
import { storeStrings, translate, translateError } from './utils.js'
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -75,25 +76,9 @@ class LangModule extends AbstractModule {
|
|
|
75
76
|
|
|
76
77
|
server.api.addMiddleware(this.addTranslationUtils.bind(this))
|
|
77
78
|
|
|
78
|
-
const
|
|
79
|
-
router.
|
|
80
|
-
|
|
81
|
-
handlers: { get: this.requestHandler.bind(this) },
|
|
82
|
-
meta: {
|
|
83
|
-
get: {
|
|
84
|
-
summary: 'Retrieve lang strings for single locale',
|
|
85
|
-
responses: {
|
|
86
|
-
200: {
|
|
87
|
-
description: 'Lang strings for the specified locale',
|
|
88
|
-
content: {
|
|
89
|
-
'application/json': {}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
auth.unsecureRoute(router.path, 'get')
|
|
79
|
+
const config = await loadRouteConfig(this.rootDir, this)
|
|
80
|
+
const router = server.api.createChildRouter(config.root)
|
|
81
|
+
registerRoutes(router, config.routes, auth)
|
|
97
82
|
}
|
|
98
83
|
|
|
99
84
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "adapt-authoring-lang",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Localisation for the Adapt authoring tool",
|
|
5
5
|
"homepage": "https://github.com/taylortom/adapt-authoring-lang",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"adapt-authoring-auth": "^2.0.0",
|
|
22
|
-
"adapt-authoring-server": "^2.
|
|
22
|
+
"adapt-authoring-server": "^2.1.0"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@semantic-release/git": "^10.0.1",
|
package/routes.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": "lang",
|
|
3
|
+
"routes": [
|
|
4
|
+
{
|
|
5
|
+
"route": "/{:lang}",
|
|
6
|
+
"handlers": { "get": "requestHandler" },
|
|
7
|
+
"permissions": { "get": null },
|
|
8
|
+
"meta": {
|
|
9
|
+
"get": {
|
|
10
|
+
"summary": "Retrieve lang strings for single locale",
|
|
11
|
+
"responses": {
|
|
12
|
+
"200": {
|
|
13
|
+
"description": "Lang strings for the specified locale",
|
|
14
|
+
"content": {
|
|
15
|
+
"application/json": {}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|