bajo 1.1.1 → 1.1.2

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.
@@ -570,32 +570,35 @@ class BajoCore extends Plugin {
570
570
  return dt.toDate()
571
571
  }
572
572
 
573
- parseObject = (input, { silent = true, parseValue = false, lang, ns } = {}) => {
573
+ parseObject = (input, options = {}) => {
574
+ const { silent = true, parseValue = false, lang, ns } = options
575
+ const translate = (item) => {
576
+ const scope = ns ? this.app[ns] : this
577
+ const [text, ...args] = item.split('|')
578
+ return scope.print.write(text, ...args, { lang })
579
+ }
574
580
  const statics = ['*']
575
581
  let obj = cloneDeep(input)
576
582
  const keys = Object.keys(obj)
577
- const me = this
578
583
  const mutated = []
579
584
  keys.forEach(k => {
580
- const v = obj[k]
581
- if (isPlainObject(v)) obj[k] = this.parseObject(v)
585
+ let v = obj[k]
586
+ if (isPlainObject(v)) obj[k] = this.parseObject(v, options)
582
587
  else if (isArray(v)) {
583
588
  v.forEach((i, idx) => {
584
- if (isPlainObject(i)) obj[k][idx] = this.parseObject(i)
589
+ if (isPlainObject(i)) obj[k][idx] = this.parseObject(i, options)
585
590
  else if (statics.includes(i)) obj[k][idx] = i
586
591
  else if (parseValue) obj[k][idx] = dotenvParseVariables(set({}, 'item', obj[k][idx]), { assignToProcessEnv: false }).item
587
592
  if (isArray(obj[k][idx])) obj[k][idx] = obj[k][idx].map(item => typeof item === 'string' ? item.trim() : item)
588
593
  })
589
594
  } else if (this.isSet(v)) {
595
+ if (isString(v) && v.startsWith('t:') && lang) v = translate(v.slice(2))
590
596
  try {
591
597
  if (statics.includes(v)) obj[k] = v
592
598
  else if (k.startsWith('t:') && isString(v)) {
593
599
  const newK = k.slice(2)
594
- if (lang) {
595
- const scope = ns ? me.app[ns] : me
596
- const [text, ...args] = v.split('|')
597
- obj[newK] = scope.print.write(text, ...args, { lang })
598
- } else obj[newK] = v
600
+ if (lang) obj[newK] = translate(v)
601
+ else obj[newK] = v
599
602
  mutated.push(k)
600
603
  } else if (parseValue) {
601
604
  obj[k] = dotenvParseVariables(set({}, 'item', v), { assignToProcessEnv: false }).item
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "A framework to build a giant monstrous app rapidly",
5
5
  "main": "boot/index.js",
6
6
  "scripts": {