zendesk/app_scaffold

translations-loader.js is only copying the "app" key

Closed this issue · 3 comments

Using the following file as an example:

{
  "app": {
    "description": "add your app description here",
    "name": "add your app name here"
  },

  "hello": "Hello {{name}}!",

  "save": {
    "button": "Bookmark ticket #{{id}}",
    "success": "Bookmarked ticket #{{id}}",
    "error": "Sorry, something went wrong."
  },

  "learn_more": {
    "message": "To learn more, {{link}}",
    "link_text": "see the Zendesk forums"
  }
}

will produce this in the dist folder:

{
  "_warning": "AUTOMATICALLY GENERATED FROM src/translations/en.json - DO NOT MODIFY THIS FILE DIRECTLY",
  "app": {
    "name": "add your app name here",
    "description": "add your app description here"
  }
}

If I remove the "app" key, I get this when "webpack --watch" runs:

WARNING in ./src/translations/en.json
Module build failed: TypeError: Cannot use 'in' operator to search for 'name' in undefined
    at /Users/Me/Zendesk Apps/app_scaffold-master/lib/loaders/translations-loader.js:38:28
    at Array.forEach (native)
    at extractMarketplaceTranslation (/Users/Me/Zendesk Apps/app_scaffold-master/lib/loaders/translations-loader.js:37:17)
    at Object.TranslationsLoader (/Users/Me/Zendesk Apps/app_scaffold-master/lib/loaders/translations-loader.js:58:33)
@ ./src/translations ^./.*.json$

Am I doing something wrong?

From what I understand, it only copies the app key because that's what it needs outside the app itself (eg: the apps manage page in the account). The other translations are included in the .js file that gets created inside the dist folder. Same goes for the .hdbs templates.

@aculligan is correct, but we could probably improve error handling for this. Thanks for reporting.

{
"_warning": "AUTOMATICALLY GENERATED FROM src/translations/en.json - DO NOT MODIFY THIS FILE DIRECTLY",
"app": {
"name": "add your app name here",
"description": "add your app description here"
}
}