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?

Comments

vijaycs85’s picture

Status: Active » Needs review
Issue tags: +sprint, +Needs manual testing
StatusFileSize
new544 bytes

I guess the problem is from date/date_elements.inc.

Status: Needs review » Needs work

The last submitted patch, 1: 2101397-title-translation-1.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: 2101397-title-translation-1.patch, failed testing.

wwedding’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1: 2101397-title-translation-1.patch, failed testing.

The last submitted patch, 1: 2101397-title-translation-1.patch, failed testing.

wwedding’s picture

I'm not sure what is making this fail testing so spectacularly. I just tested another patch just fine, and this tests fine locally.

wwedding’s picture

Version: 7.x-2.6 » 7.x-2.x-dev
Status: Needs work » Needs review
wwedding’s picture

vijaycs85’s picture

Assigned: Unassigned » podarok
Status: Needs review » Reviewed & tested by the community

nice catch @stickywes. Assigning to @podarok for further review and commit

podarok’s picture

Status: Reviewed & tested by the community » Fixed

commited
thanks!

  • Commit bf72222 on 7.x-2.x authored by vijaycs85, committed by podarok:
    Issue #2146461 by vijaycs85 | Razia_b: Fixed Translated field's label is...
vijaycs85’s picture

Issue tags: -sprint

yay! thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nils.destoop’s picture

Status: Closed (fixed) » Active

This issue is not fixed. The patch can never work:

 t('@field_name', array('@field_name' => $instance['label']));

will always have same result as before the patch ($instance['label']). As the label is just added as replacement.

nils.destoop’s picture

StatusFileSize
new1.82 KB

Attached is a patch that fixes the issue.
i18n_field does this:

      // Translate field title if set
      if (!empty($instance['label'])) {
        $element['#title'] = i18n_field_translate_property($instance, 'label');
      }

So $element['#title'] should be used instead of $instance['label']

wwedding’s picture

Status: Active » Needs review
krizbeckmann’s picture

For me, #17 does the trick. Thnx :)

damienmckenna’s picture

Assigned: podarok » Unassigned

Reminder: 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.

damienmckenna’s picture

StatusFileSize
new1.41 KB

Rerolled.