-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translation with params not included in payload generation #5302
Translation with params not included in payload generation #5302
Conversation
✅ Deploy Preview for dev-web-novu ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -33,7 +33,7 @@ export class UpdateMessageTemplate { | |||
updatePayload.name = command.name; | |||
} | |||
|
|||
if (command.content !== null) { | |||
if (command.content !== null || command.content !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to a different PR, added it here after a comment there
const pairVariables = bod | ||
.filter((body) => body.type === 'HashPair') | ||
.flatMap((body) => { | ||
const varName = body.value?.original as string; | ||
|
||
if (!shouldAddVariable(varName)) { | ||
return []; | ||
} | ||
|
||
return { | ||
type: TemplateVariableTypeEnum.STRING, | ||
name: body.value?.original as string, | ||
defaultValue: '', | ||
required: false, | ||
}; | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be used in the future for other handlebars helpers that we might want to allow variables assignments in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should extract it to a reusable function then?
…ith-params-not-included-in-payload-generation
|
||
return { | ||
type: TemplateVariableTypeEnum.STRING, | ||
name: body.value?.original as string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name: body.value?.original as string, | |
name: varName, |
const pairVariables = bod | ||
.filter((body) => body.type === 'HashPair') | ||
.flatMap((body) => { | ||
const varName = body.value?.original as string; | ||
|
||
if (!shouldAddVariable(varName)) { | ||
return []; | ||
} | ||
|
||
return { | ||
type: TemplateVariableTypeEnum.STRING, | ||
name: body.value?.original as string, | ||
defaultValue: '', | ||
required: false, | ||
}; | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should extract it to a reusable function then?
if (body.path.original === HandlebarHelpersEnum.I18N) { | ||
if (body.path?.original === HandlebarHelpersEnum.I18N) { | ||
if (body.hash?.pairs) { | ||
return getTemplateVariables(body.hash.pairs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we need a recurrent call here?
Can't we just use the extracted above function (lines 13-29) to get the variables?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, yes, you are right @LetItRock . But when we have time, in the cooldown maybe I want to go back to it and add support for sub expressions. In i18n, but also for general use. And that will need the recurrent calls.
For example:
{{titlecase (uppercase msg) }}
(not a useful example, but just to show my point)
or for i18n
{{i18n "group.key" var=(titlecase msg) }}
msg
in both examples would not be recognized as a variable, and in the first example it would set uppercase
as a variable instead.
I do have something working for those states, but it requires some more work. I didn't want to over do it with the time as I feel its not the biggest priority
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, makes sense now :)
…ror-jsonparseanonymous Unhandled Error: SyntaxError JSON.parse(<anonymous>)
…-in-payload-generation
What change does this PR introduce?
Params used within a translation are not being recognized as workflow variables and are not included in the created payload trigger.
example:
{{i18n "test.key" var=payload-var}}
=>payload-var
should be included in the trigger snippet :novu.trigger(......, payload: { payload-var: ...})
Why was this change needed?
Other information (Screenshots)