boxwood 0.70.0 → 0.70.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.
Files changed (2) hide show
  1. package/index.js +21 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -477,7 +477,16 @@ 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
- return data[key][language]
480
+ if (!language) {
481
+ throw new Error("TranslationError[method]: language is undefined")
482
+ }
483
+ const translation = data[key][language]
484
+ if (!translation) {
485
+ throw new Error(
486
+ `TranslationError[method]: translation for [${key}][${language}] is undefined`
487
+ )
488
+ }
489
+ return translation
481
490
  }
482
491
  }
483
492
 
@@ -487,8 +496,18 @@ function component(fn, { styles, i18n } = {}) {
487
496
  return fn({}, a)
488
497
  }
489
498
  if (i18n) {
499
+ const { language } = a
490
500
  function translate(key) {
491
- return i18n[key][a.language]
501
+ if (!language) {
502
+ throw new Error("TranslationError[component]: language is undefined")
503
+ }
504
+ const translation = i18n[key][language]
505
+ if (!translation) {
506
+ throw new Error(
507
+ `TranslationError[component]: translation for [${key}][${language}] is undefined`
508
+ )
509
+ }
510
+ return translation
492
511
  }
493
512
  return fn({ ...a, translate }, b || [])
494
513
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.70.0",
3
+ "version": "0.70.1",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {