Problem/Motivation
If a part of datelist is not filled, you see a translatable error with a description which parts are not filled.
However, the names of the parts are not translatable because they are pasted as simple string literal parameters:
// The $value might be either "year", "month" or "day".
$form_state->setError($element[$value], t('A value must be selected for %part.', ['%part' => $value]));
Proposed resolution
Wrap the $value variable with t() function.
Remaining tasks
None.
User interface changes
Fully translatable error messages for invalid datetime fields.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#16 | 2938010-nr-bot.txt | 1.79 KB | needs-review-queue-bot |
#9 | 2938010-09.patch | 1.49 KB | jhedstrom |
#5 | screenshot-2018-04-24.png | 27.07 KB | jml16 |
Comments
Comment #2
y.litovchenko CreditAttribution: y.litovchenko commentedComment #3
y.litovchenko CreditAttribution: y.litovchenko commentedComment #4
mpdonadioConfused here. Shouldn those labels already be translated as part of Datelist::processDatelist()?
What language are you using? Can you post a screenshot of the widget + error message?
Comment #5
jml16 CreditAttribution: jml16 commentedHi, here you have the screenshot in spanish.
Comment #6
mpdonadioThanks for the screenshot. I think we need to add a test here.
Comment #8
jhedstromUsing variables inside the
t()
function is usually not recommended.I wonder instead if we need to translate the
#date_part_order
key ingetInfo()
:Note that it isn't as simple as just wrapping those values in
t()
since those are actual markup elements.The root of this issue is that we're using machine names in the UI in this warning instead of a translatable label.
This also still needs tests, so setting to NW.
Comment #9
jhedstromI'm not actually sure how to right language/translation tests...
This patch implements what I described in #8.
Comment #16
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.