Problem/Motivation
In #3051503: Implement a confirmation form before the transition the option for confirmation forms was included and a question was phrased in comments 18-20. However I ran into issues when adding translations for this question.
The question Are you sure you want to %transition_label @entity_label? made (for me) sense in English as you will get questions like:
- Are you sure you want to [place order] [1]?
- Are you sure you want to [promote] [Bob]
- Are you sure you want to [promote user] [Bob]
- Are you sure you want to [publish content] [My cool node title]
But, because the transition label is a fixed string, this is proving difficult to translate.
"Are you sure you want to place order 1?" would translate in Dutch to "Weet u zeker dat u order 1 wilt plaatsen?". "Place order" translates to "order plaatsen", which works on a button, but in a sentence these words are no longer next to each other.
Proposal
I suppose the only way to overcome this, is to make the question have the transition in quotes. As jsacksick kind of suggested in #3051503-18: Implement a confirmation form before the transition bullet 5.
- "Are you sure you want to apply transition '[promote user]' to [Bob]?"
- "Are you sure you want to apply transition '[place order]' to [1]?" (Commerce might need a class override or label 'Order 1'.)
- "Are you sure you want to apply transition '[publish content]' to [My cool node title]?"
Alternatively we could leave out the transition label entirely and use from and to states.
- "Are you sure you want to transition [Bob] from [junior] to [senior]?"
- "Are you sure you want to transition [1] from [draft] to [placed]?" (Commerce might need a class override or label 'Order 1'.)
- "Are you sure you want to transition [My cool node title] from [draft] to [published]?"
There probably is never going to be a fit solution for every use case, but it would be nice of the standard question can be translated into something that makes sense. (Especially for a confirmation question.)
Wondering how this would also hold up for other languages.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | 3220535-7.patch | 5.79 KB | jsacksick |
| #5 | confirm-form-with-paragraph.png | 27.08 KB | jsacksick |
| #5 | confirm-form-with-list.png | 27.22 KB | jsacksick |
Comments
Comment #2
jsacksick commentedSince we're already in "context", and especially when combined with the modal (introduced in #3220573: Add option to display confirmation form in a modal to the formatter), I'm thinking omitting the entity label could be fine... (i.e Are you sure you want to "Place order"?).
Regarding your suggestions, we could also do:
When recording state transitions for orders, commerce_log defines this template:
"Order moved from <em>{{ from_state }}</em> to <em>{{ to_state }}</em> by the <em>{{ transition_label }}</em> transition."Additionally, there's one alternative option we haven't explored yet which is to update the description text, which currently simply says "This action cannot be undone".
The description could say something like the following instead:
Clicking on '%transition_label' will move the %entity_label from %from_state to %to_state. This action cannot be undone.Though if we go this route, it'll also be complex to find a description text that fits for all entity types / transitions.
Comment #3
rszrama commentedGreat feedback! I see a problem even in the use of the word "to" in the sentence, because in English, "to" is what signifies an infinitive (e.g. "to place"), while other languages just use a different case ... meaning "place" itself would be morphed to represent the infinitive, even though in the original context "place" is an imperative. Practically speaking, I think it will be impossible to have a "correct" sentence that's meaningfully translatable.
So ... I actually really like Jonathan's suggestion as an elegant workaround that trades out a "nice" full sentence for having a simple question ("Are you sure you want to apply this transition?") with technical details. It may not be as user-friendly to the merchant, but it'll be absolutely clear.
My proposal would essentially be:
(I'm just not sure if we need to bold the items on the left or not ... may be necessary for readability.)
Comment #4
neograph734That makes sense and cannot go wrong, but perhaps ensure that the original "this cannot be undone" also remains?
Comment #5
jsacksick commentedThe attached patch implements the proposal from #3.
If we all come to an agreement, we can commit this, tag a new release so Commerce can require State machine 1.4 and benefit from the modals in the next version that's planned for tomorrow (2.25).
Tried 2 different versions:
Using a list:
Using a regular paragraph (option chosen):
Thoughts?
Comment #6
jsacksick commentedFixed phpcs violations.
Comment #7
jsacksick commentedAs a side note, it feels a bit weird to not get a confirmation message... But that's another issue that we can probably address later.
Comment #8
mglamanYou can do this on a protected method? You need a setter method for the property.
You should use `renderPlain` here to avoid leaked cache data.
Comment #9
jsacksick commentedYes, and core does that in multiple places.
Done!
Comment #10
mglaman+1 looks good to me.
Comment #11
neograph734Modal looks good and the text is super clear without the need for difficult translations. Great! I too think option 2 looks the best.
I am having some issues with submitting the form without the modal though, but I suppose that might have been caused by #3220573: Add option to display confirmation form in a modal to the formatter instead? (I have some more feedback on that issue that you might want to get in the release...)
Comment #12
neograph734Comment #14
jsacksick commentedCommitted! Thanks everyone!