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.
- package/index.js +16 -4
- 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(
|
|
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[
|
|
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(
|
|
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[
|
|
519
|
+
`TranslationError[${key}][${language}]: translation is undefined for component:\n${fn.toString()}`
|
|
508
520
|
)
|
|
509
521
|
}
|
|
510
522
|
return translation
|