Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
new things and such
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasbarth committed May 6, 2022
1 parent e2a8d88 commit 102db40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions generate/Dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ module.exports = class Dialog {
return this;
}

getText(key, params = {}) {
getText(key, params = {}, errorOnMissingKey = true) {
const value = this.i18n.t(key, { ...params, returnObjects: true });
// i18next returns the key if the value isn't available in the locale, or
// fallback translation.
// TODO: Discuss how to verify that each function will return a valid dialog text

if (value === key) {
throw new Error('No translation key available for key [' + key + '].');
if (errorOnMissingKey) {
throw new Error('No translation key available for key [' + key + '].');
}

return ''
}

if (Array.isArray(value)) {
Expand Down
2 changes: 1 addition & 1 deletion utils/craftResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = ({
return ''
}

const response = dialogMap[state] ? dialogMap[state](context, dialog) : dialog(`${conversationType}.${state}`, context)
const response = dialogMap[state] ? dialogMap[state](context, dialog) : dialog(`${conversationType}.${state}`, context, false)

return context.resuming && !overrideResume && dialogMap.resume(context) ?
`${dialogMap.resume(context)} ${response}` : response
Expand Down

0 comments on commit 102db40

Please sign in to comment.