boxwood 0.65.0 → 0.66.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/index.js +12 -0
- package/package.json +3 -2
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ const { join } = require("path")
|
|
|
2
2
|
const { readFileSync } = require("fs")
|
|
3
3
|
const csstree = require("css-tree")
|
|
4
4
|
const toHash = require("string-hash")
|
|
5
|
+
const YAML = require("yaml")
|
|
5
6
|
|
|
6
7
|
async function compile(path) {
|
|
7
8
|
const fn = require(path)
|
|
@@ -458,6 +459,17 @@ function i18n(translations) {
|
|
|
458
459
|
}
|
|
459
460
|
}
|
|
460
461
|
|
|
462
|
+
i18n.load = function () {
|
|
463
|
+
const path = join(...arguments)
|
|
464
|
+
const content = readFileSync(path, "utf8")
|
|
465
|
+
const data = path.endsWith(".yaml")
|
|
466
|
+
? YAML.parse(content)
|
|
467
|
+
: JSON.parse(content)
|
|
468
|
+
return function translate(language, key) {
|
|
469
|
+
return data[key][language]
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
461
473
|
module.exports = {
|
|
462
474
|
compile,
|
|
463
475
|
classes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "boxwood",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.66.0",
|
|
4
4
|
"description": "Compile HTML templates into JS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"css-tree": "^2.3.1",
|
|
67
|
-
"string-hash": "^1.1.3"
|
|
67
|
+
"string-hash": "^1.1.3",
|
|
68
|
+
"yaml": "^2.2.1"
|
|
68
69
|
}
|
|
69
70
|
}
|