bajo 2.11.0 → 2.11.1
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/class/bajo.js +14 -12
- package/extend/bajo/intl/en-US.json +3 -1
- package/extend/bajo/intl/id.json +3 -1
- package/package.json +1 -1
- package/wiki/CHANGES.md +5 -0
package/class/bajo.js
CHANGED
|
@@ -301,15 +301,14 @@ class Bajo extends Plugin {
|
|
|
301
301
|
scope = item
|
|
302
302
|
item = args.shift()
|
|
303
303
|
}
|
|
304
|
-
const bajo = scope.app.bajo
|
|
305
304
|
if (isString(item)) {
|
|
306
|
-
if (item.startsWith('applet:') &&
|
|
305
|
+
if (item.startsWith('applet:') && this.app.applets.length > 0) {
|
|
307
306
|
const [, ns, path] = item.split(':')
|
|
308
|
-
const applet = find(
|
|
309
|
-
if (applet &&
|
|
307
|
+
const applet = find(this.app.applets, a => (a.ns === ns || a.alias === ns))
|
|
308
|
+
if (applet && this.app.bajoCli) result = await this.app.bajoCli.runApplet(applet, path, ...args)
|
|
310
309
|
} else {
|
|
311
310
|
const [ns, method, ...params] = item.split(':')
|
|
312
|
-
const fn =
|
|
311
|
+
const fn = this.getMethod(`${ns}:${method}`)
|
|
313
312
|
if (fn) {
|
|
314
313
|
if (params.length > 0) args.unshift(...params)
|
|
315
314
|
result = await fn(...args)
|
|
@@ -454,7 +453,7 @@ class Bajo extends Plugin {
|
|
|
454
453
|
* @returns {string} Formatted value
|
|
455
454
|
*/
|
|
456
455
|
format = (value, type, options = {}) => {
|
|
457
|
-
const { defaultsDeep } = this.app.lib.aneka
|
|
456
|
+
const { defaultsDeep, isSet } = this.app.lib.aneka
|
|
458
457
|
const { format } = this.config.intl
|
|
459
458
|
const { emptyValue = format.emptyValue } = options
|
|
460
459
|
const lang = options.lang ?? this.config.lang
|
|
@@ -496,6 +495,7 @@ class Bajo extends Plugin {
|
|
|
496
495
|
}
|
|
497
496
|
if (['array'].includes(type)) return value.join(', ')
|
|
498
497
|
if (['object'].includes(type)) return JSON.stringify(value)
|
|
498
|
+
if (['boolean'].includes(type) && isSet(value)) return value ? this.t('true', { lang }) : this.t('false', { lang })
|
|
499
499
|
return value
|
|
500
500
|
}
|
|
501
501
|
|
|
@@ -800,15 +800,17 @@ class Bajo extends Plugin {
|
|
|
800
800
|
* @param {string} [options.lastSeparator=and] - Text to use as the last separator
|
|
801
801
|
* @returns {string}
|
|
802
802
|
*/
|
|
803
|
-
join = (array, options) => {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
803
|
+
join = (array, options = {}) => {
|
|
804
|
+
let separator = ', '
|
|
805
|
+
let lastSeparator = 'and'
|
|
806
|
+
let lang
|
|
807
|
+
if (isString(options)) separator = options
|
|
808
|
+
else ({ separator, lastSeparator, lang } = options)
|
|
809
|
+
const translate = (val) => {
|
|
810
|
+
return this.t(val, { lang }).toLowerCase()
|
|
807
811
|
}
|
|
808
812
|
if (array.length === 0) return translate('none')
|
|
809
813
|
if (array.length === 1) return array[0]
|
|
810
|
-
if (isSet(options) && !isPlainObject(options)) return array.join(options)
|
|
811
|
-
let { separator = ', ', lastSeparator = 'and' } = options ?? {}
|
|
812
814
|
lastSeparator = translate(lastSeparator)
|
|
813
815
|
const last = (array.pop() ?? '').trim()
|
|
814
816
|
return array.map(a => (a + '').trim()).join(separator) + ` ${lastSeparator} ${last}`
|
|
@@ -182,5 +182,7 @@
|
|
|
182
182
|
"fieldError%s%s": "'%s': %s|lowerFirst",
|
|
183
183
|
"reservedName%s%s": "%s|upperFirst name '%s' is a reserved name. Please rename to something else",
|
|
184
184
|
"missing%s%s": "Missing '%s' %s",
|
|
185
|
-
"processing...": "Processing..."
|
|
185
|
+
"processing...": "Processing...",
|
|
186
|
+
"true": "True",
|
|
187
|
+
"false": "False"
|
|
186
188
|
}
|
package/extend/bajo/intl/id.json
CHANGED
|
@@ -182,5 +182,7 @@
|
|
|
182
182
|
"fieldError%s%s": "'%s': %s|lowerFirst",
|
|
183
183
|
"reservedName%s%s": "Nama %s|lowerFirst '%s' adalah nama tang di reserve. Silahkan gunakan nama lainnya",
|
|
184
184
|
"missing%s%s": "%s|upperFirst '%s' tidak ditemukan",
|
|
185
|
-
"processing...": "Memroses..."
|
|
185
|
+
"processing...": "Memroses...",
|
|
186
|
+
"true": "Benar",
|
|
187
|
+
"false": "Salah"
|
|
186
188
|
}
|
package/package.json
CHANGED