I have a form with a date field in it. By using i18n module I have translated the field’s label/title in French. Next, I need to translate the field’s validation message. The i18n gives me this translatable message string in which field title is used as a placeholder. In string French translation, I have used that placeholder. But English field title appears in French translated message.
Translation is performed as following:
Eng: A valid date is required for %title.
French Translation: %title est un champ obligatoire
I did some debugging and found that the date module gets un translated field label and utilize that in setting validation messages.
Relevant code in date_api_elements.inc @ line 673
$label = !empty($element['#date_title']) ? $element['#date_title'] : (!empty($element['#title']) ? $element['#title'] : '');
This untranslaeted label is further used in validation messages.
Relevant code in date_api_elements.inc @ line 698
$message = t('A valid date is required for %title.', array('%title' => $label));
There is some kind of change required in date_api_elements.inc @ line 673 to get a relevant translated field label to further use in setting feedback/validate messages. How do I change this?
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | date-n2146461-21.patch | 1.41 KB | damienmckenna |
| #17 | 2146461-17.patch | 1.82 KB | nils.destoop |
| #1 | 2101397-title-translation-1.patch | 544 bytes | vijaycs85 |
Comments
Comment #1
vijaycs85I guess the problem is from date/date_elements.inc.
Comment #3
vijaycs851: 2101397-title-translation-1.patch queued for re-testing.
Comment #5
wwedding commented1: 2101397-title-translation-1.patch queued for re-testing.
Comment #8
wwedding commentedI'm not sure what is making this fail testing so spectacularly. I just tested another patch just fine, and this tests fine locally.
Comment #9
wwedding commentedComment #10
wwedding commented1: 2101397-title-translation-1.patch queued for re-testing.
Comment #11
vijaycs85nice catch @stickywes. Assigning to @podarok for further review and commit
Comment #12
podarokcommited
thanks!
Comment #14
vijaycs85yay! thanks.
Comment #16
nils.destoop commentedThis issue is not fixed. The patch can never work:
will always have same result as before the patch ($instance['label']). As the label is just added as replacement.
Comment #17
nils.destoop commentedAttached is a patch that fixes the issue.
i18n_field does this:
So $element['#title'] should be used instead of $instance['label']
Comment #18
wwedding commentedComment #19
krizbeckmann commentedFor me, #17 does the trick. Thnx :)
Comment #20
damienmckennaReminder: the "assigned" field is for indicating that you are actively working on something, it is not for indicating that you reported a problem or that you previously worked on a problem and would like attribution. Thanks.
Comment #21
damienmckennaRerolled.