boxwood 0.70.1 → 0.71.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.
Files changed (2) hide show
  1. package/index.js +18 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -438,6 +438,8 @@ function classes() {
438
438
  const type = typeof arg
439
439
  if (type === "string") {
440
440
  array.push(arg)
441
+ } else if (Array.isArray(arg)) {
442
+ array.push(classes(...arg))
441
443
  } else if (type === "object") {
442
444
  for (const key in arg) {
443
445
  if (arg[key]) {
@@ -477,13 +479,18 @@ i18n.load = function () {
477
479
  const path = join(...arguments)
478
480
  const data = path.endsWith(".yaml") ? yaml.load(path) : json.load(path)
479
481
  return function translate(language, key) {
482
+ if (!key) {
483
+ throw new Error(`TranslationError[${key}][${language}]: key is undefined`)
484
+ }
480
485
  if (!language) {
481
- throw new Error("TranslationError[method]: language is undefined")
486
+ throw new Error(
487
+ `TranslationError[${key}][${language}]: language is undefined`
488
+ )
482
489
  }
483
490
  const translation = data[key][language]
484
491
  if (!translation) {
485
492
  throw new Error(
486
- `TranslationError[method]: translation for [${key}][${language}] is undefined`
493
+ `TranslationError[${key}][${language}]: translation is undefined`
487
494
  )
488
495
  }
489
496
  return translation
@@ -498,13 +505,20 @@ function component(fn, { styles, i18n } = {}) {
498
505
  if (i18n) {
499
506
  const { language } = a
500
507
  function translate(key) {
508
+ if (!key) {
509
+ throw new Error(
510
+ `TranslationError[${key}][${language}]: key is undefined for component:\n${fn.toString()}`
511
+ )
512
+ }
501
513
  if (!language) {
502
- throw new Error("TranslationError[component]: language is undefined")
514
+ throw new Error(
515
+ `TranslationError[${key}][${language}]: language is undefined for component:\n${fn.toString()}`
516
+ )
503
517
  }
504
518
  const translation = i18n[key][language]
505
519
  if (!translation) {
506
520
  throw new Error(
507
- `TranslationError[component]: translation for [${key}][${language}] is undefined`
521
+ `TranslationError[${key}][${language}]: translation is undefined for component:\n${fn.toString()}`
508
522
  )
509
523
  }
510
524
  return translation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.70.1",
3
+ "version": "0.71.0",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {