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