Skip to content

Commit

Permalink
Throw error when translation keys are not found
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jul 25, 2019
1 parent 43cac0f commit 904c822
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/resource/ResourceHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class ResourceHandler {
return null;
}
let file = nbts[nbt];
if (!file && !nbt) {
if (!file) {
file = nbts[Object.keys(nbts)[0]]; // Take the first NBT-tagged item if none without NBT could be found
}
return file;
Expand Down
13 changes: 10 additions & 3 deletions lib/serialize/HtmlInfoBookSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ export class HtmlInfoBookSerializer {
}
const iconUrl = fileWriter.write('icons/' + basename(icon), createReadStream(icon));

const { link, linkTarget } = this.createResourceLink(resourceHandler, context, item.item,
resourceHandler.getItemTranslationKey(item));
const key = resourceHandler.getItemTranslationKey(item);
if (!key) {
throw new Error(`Could not find translation key for item ${JSON.stringify(item)}`);
}
const { link, linkTarget } = this.createResourceLink(resourceHandler, context, item.item, key);

return this.templateItem({
...context,
Expand All @@ -276,8 +279,12 @@ export class HtmlInfoBookSerializer {
}
const iconUrl = fileWriter.write('icons/' + basename(icon), createReadStream(icon));

const key = resourceHandler.getFluidTranslationKey(fluid);
if (!key) {
throw new Error(`Could not find translation key for fluid ${JSON.stringify(fluid)}`);
}
const { link, linkTarget } = this.createResourceLink(resourceHandler, context, this.tagFluid(context, fluid.fluid),
resourceHandler.getFluidTranslationKey(fluid));
key);

return this.templateItem({
...context,
Expand Down

0 comments on commit 904c822

Please sign in to comment.