-
Notifications
You must be signed in to change notification settings - Fork 38
Feedback presend warning
The feedback presend warning system (PSW) is a mechanism that warns the feedback writer before submitting a feedback with a specific RegEx triggers.
How it works is when the Submit button is pressed and a RegEx pattern matches the feedback content, a warning will be shown, and the submit button will be disabled for 5 seconds. If 5 seconds have elapsed, and nothing is changed on the content field, the Submit button can be pressed again and the feedback will be submitted. It is the developer's wish that the user to reconsider sending the feedback when the warning is shown.
To add a warning, do the following steps:
-
Add the relevant i18n key strings on
i18n/en.yml
.Inside the
FeedbackPage.PreSendWarning
dictionary, add a dictionary with the key of the warning ID you choose. Inside of this dictionary, add strings withHeading
andDescription
as the key. In some cases, the dictionary may be adjusted, but the previously mentioned format is recommended.The
Heading
string should be short enough, but still convoys the reasoning of the warning being triggered (e.g. if the trigger is related tothemes
, the heading should havethemes
on it, likeSome themes are not working due to a bug.
The
Description
string should include additional information related to the warning, such as contexts related to the bug, advices to work around the bug, relevant links, etc.Placeholders (e.g.
{{ .Tag1Start }}
) can be added as you wish.For example, here's an example with the warning ID of
NotST
.FeedbackPage: # ... PreSendWarning: # ... NotST: Heading: We are not the Scratch Team. Description: Keep in mind that Scratch Addons is not affiliated with the Scratch website or the organizations that maintain it.
-
Add the relevant object on
layouts/shortcodes/specifics/feedback-form.html
Inside
window.i18nStrings.preSendWarning.variations
(thewindow.i18nStrings
object, then inside of it,preSendWarning.variations
), add a object with the key of the warning ID you choose, but incamelCase
. Inside of this object, add strings withheading
anddescription
as the key. In some cases, the object may be adjusted, but the previously mentioned format is recommended.If there are placeholders (e.g.
{{ .Tag1Start }}
), you should use the$ts
value to fill the placeholder. Since the system replaces the placeholder value in JavaScript (not Hugo), it needs to use the$ts
value to differentiate the strings from the translators and the placeholder itself.For example, here's an example with the warning ID of
NotST
.window.i18nStrings = { // ... preSendWarning: { // ... variations: { // ... notST: { heading: '{{ T "FeedbackPage.PreSendWarning.Variations.NotST.Heading" }}', description: '{{ T "FeedbackPage.PreSendWarning.Variations.NotST.Description" | htmlEscape }}', }, } }, }
-
Add the relevant object on
static/assets/js/feedback.js
Inside
variations
, add a object with the key of the warning ID you choose, but incamelCase
. Inside of this object, addstrings
that contain the strings (...i18n.preSendWarning.variations.warningId
) andpatterns
that contain the RegEx patterns that will trigger the warning in an array.If there are placeholders (e.g.
{{ .Tag1Start }}
), you should replace the$ts
placeholders with the real values.For example, here's an example with the warning ID of
NotST
.const variations = { // ... notST: { strings: { ...i18n.preSendWarning.variations.notST }, patterns: [ /\bscratch\s*team\b/i, /\bst\b/, ] }, }
To remove a warning, remove the added parts mentioned on the previous section. For temporary warnings, the recommended time to remove the warning is on the next minor release of Scratch Addons.
© 2024 Scratch Addons contributors. Licensed under the terms of GNU General Public License v3.0.
Any issues? Have questions? Tell them here.
- Themes
- Changelog data structure
- Specific Hugo changes
- Blog
- Internationalization/Localization/Translation (i18n)
- Feedback presend warning
- Addon Docs
- Integration status dashboard