bajo 2.13.0 → 2.13.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/app.js +7 -0
- package/class/bajo.js +4 -6
- package/package.json +1 -1
- package/wiki/CHANGES.md +5 -0
package/class/app.js
CHANGED
|
@@ -382,8 +382,15 @@ class App {
|
|
|
382
382
|
*/
|
|
383
383
|
t = (ns, text, ...params) => {
|
|
384
384
|
const { formatText, isSet } = this.lib.aneka
|
|
385
|
+
const { isArray, last } = this.lib._
|
|
386
|
+
const { join } = this.bajo
|
|
385
387
|
let { text: newText, trans, params: args } = this._prepTrans(ns, text, params)
|
|
386
388
|
if (!isSet(trans)) trans = newText
|
|
389
|
+
const lang = isPlainObject(last(args)) ? last(args).lang : undefined
|
|
390
|
+
for (const idx in args) {
|
|
391
|
+
const arg = args[idx]
|
|
392
|
+
if (isArray(arg)) args[idx] = join(arg, { lang })
|
|
393
|
+
}
|
|
387
394
|
return formatText(trans, ...args)
|
|
388
395
|
}
|
|
389
396
|
|
package/class/bajo.js
CHANGED
|
@@ -800,12 +800,10 @@ 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 = (
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
let lang
|
|
807
|
-
if (isString(options)) separator = options
|
|
808
|
-
else ({ separator, lastSeparator, lang } = options)
|
|
803
|
+
join = (input = [], options = {}) => {
|
|
804
|
+
const array = [...input]
|
|
805
|
+
if (isString(options)) options = { separator: options }
|
|
806
|
+
let { separator = ', ', lastSeparator = 'and', lang } = options
|
|
809
807
|
const translate = (val) => {
|
|
810
808
|
return this.t(val, { lang }).toLowerCase()
|
|
811
809
|
}
|
package/package.json
CHANGED