bajo 1.0.8 → 1.0.10
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/bajo/intl/en-US.json +5 -4
- package/bajo/intl/id.json +5 -3
- package/boot/class/app.js +1 -1
- package/boot/class/bajo-core/method/extract-text.js +15 -0
- package/boot/class/bajo-core/method/get-plugin-file.js +1 -0
- package/boot/class/bajo-core/method/join.js +3 -3
- package/boot/class/bajo-core/method/parse-object.js +2 -7
- package/boot/class/error.js +1 -1
- package/boot/class/print.js +1 -1
- package/package.json +1 -1
package/bajo/intl/en-US.json
CHANGED
|
@@ -144,8 +144,9 @@
|
|
|
144
144
|
"stop": "Stop",
|
|
145
145
|
"supportDisabled%s": "%s support is disabled",
|
|
146
146
|
"collect%s": "Collect %s",
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
"isRequired%s": "'%s' is required"
|
|
147
|
+
"and": "and",
|
|
148
|
+
"or": "or",
|
|
149
|
+
"none": "none",
|
|
150
|
+
"isRequired%s": "'%s' is required",
|
|
151
|
+
"isDisabled%s": "'%s' is disabled"
|
|
151
152
|
}
|
package/bajo/intl/id.json
CHANGED
|
@@ -144,7 +144,9 @@
|
|
|
144
144
|
"stop": "Berhentikan",
|
|
145
145
|
"supportDisabled%s": "Dukungan %s dimatikan",
|
|
146
146
|
"collect%s": "Koleksi %s",
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
147
|
+
"and": "dan",
|
|
148
|
+
"or": "atau",
|
|
149
|
+
"none": "kosong",
|
|
150
|
+
"isRequired%s": "'%s' disyaratkan",
|
|
151
|
+
"isDisabled%s": "'%s' dimatikan"
|
|
150
152
|
}
|
package/boot/class/app.js
CHANGED
|
@@ -60,9 +60,9 @@ class App {
|
|
|
60
60
|
await bootPlugins.call(bajo)
|
|
61
61
|
await exitHandler.call(bajo)
|
|
62
62
|
// boot complete
|
|
63
|
-
await bajo.runHook('bajo:bootComplete')
|
|
64
63
|
const elapsed = new Date() - bajo.runAt
|
|
65
64
|
bajo.log.info('bootCompleted%s', bajo.secToHms(elapsed, true))
|
|
65
|
+
await bajo.runHook('bajo:bootComplete')
|
|
66
66
|
if (bajo.applet) await runAsApplet.call(bajo)
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
function extractText (text, patternStart, patternEnd) {
|
|
2
|
+
let result = ''
|
|
3
|
+
const open = text.indexOf(patternStart)
|
|
4
|
+
if (open > -1) {
|
|
5
|
+
text = text.slice(open + patternStart.length)
|
|
6
|
+
const close = text.indexOf(patternEnd)
|
|
7
|
+
if (close > -1) {
|
|
8
|
+
result = text.slice(0, close)
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
const pattern = `${patternStart}${result}${patternEnd}`
|
|
12
|
+
return { result, pattern }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default extractText
|
|
@@ -5,13 +5,13 @@ const { isPlainObject } = lodash
|
|
|
5
5
|
|
|
6
6
|
function join (array, sep) {
|
|
7
7
|
const translate = val => {
|
|
8
|
-
if (this && this.print) return this.print.write(val)
|
|
8
|
+
if (this && this.print) return this.print.write(val).toLowerCase()
|
|
9
9
|
return val
|
|
10
10
|
}
|
|
11
|
-
if (array.length === 0) return translate('
|
|
11
|
+
if (array.length === 0) return translate('none')
|
|
12
12
|
if (array.length === 1) return array[0]
|
|
13
13
|
if (isSet(sep) && !isPlainObject(sep)) return array.join(sep)
|
|
14
|
-
let { separator = ', ', joiner = '
|
|
14
|
+
let { separator = ', ', joiner = 'and' } = sep ?? {}
|
|
15
15
|
joiner = translate(joiner)
|
|
16
16
|
const last = (array.pop() ?? '').trim()
|
|
17
17
|
return array.map(a => (a + '').trim()).join(separator) + ` ${joiner} ${last}`
|
|
@@ -3,7 +3,6 @@ import dotenvParseVariables from 'dotenv-parse-variables'
|
|
|
3
3
|
import ms from 'ms'
|
|
4
4
|
import dayjs from '../../../lib/dayjs.js'
|
|
5
5
|
import isSet from './is-set.js'
|
|
6
|
-
// import translate from '../../../lib/translate.js'
|
|
7
6
|
|
|
8
7
|
const { isPlainObject, isArray, isNumber, set, cloneDeep, isString, omit } = lodash
|
|
9
8
|
const statics = ['*']
|
|
@@ -40,12 +39,8 @@ function parseObject (input, { silent = true, parseValue = false, lang, ns } = {
|
|
|
40
39
|
const newK = k.slice(2)
|
|
41
40
|
if (lang) {
|
|
42
41
|
const scope = ns ? me.app[ns] : me
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (a.slice(0, 2) === 't:') a = scope.print.write(lang, a.slice(2))
|
|
46
|
-
return a
|
|
47
|
-
})
|
|
48
|
-
obj[newK] = scope.print.write(text, lang, ...args)
|
|
42
|
+
const [text, ...args] = v.split('|')
|
|
43
|
+
obj[newK] = scope.print.write(text, ...args, { lang })
|
|
49
44
|
} else obj[newK] = v
|
|
50
45
|
mutated.push(k)
|
|
51
46
|
} else if (parseValue) {
|
package/boot/class/error.js
CHANGED
|
@@ -48,7 +48,7 @@ class BajoError {
|
|
|
48
48
|
const val = get(v, 'context.value')
|
|
49
49
|
value[i] = {
|
|
50
50
|
field,
|
|
51
|
-
error: print.write(`validation.${v.type}`, v.context),
|
|
51
|
+
error: print.write(`validation.${v.type}`, v.context ?? {}, {}),
|
|
52
52
|
value: val,
|
|
53
53
|
ext: { type: v.type, context: v.context }
|
|
54
54
|
}
|
package/boot/class/print.js
CHANGED
|
@@ -35,7 +35,7 @@ class Print {
|
|
|
35
35
|
let lang = this.plugin.app.bajo.config.lang
|
|
36
36
|
if (isPlainObject(opts)) {
|
|
37
37
|
args.pop()
|
|
38
|
-
lang = opts.lang
|
|
38
|
+
if (opts.lang) lang = opts.lang
|
|
39
39
|
}
|
|
40
40
|
const { fallback, supported } = this.plugin.app.bajo.config.intl
|
|
41
41
|
if (!unknownLangWarning && !supported.includes(lang)) {
|