Hello, I've Addess field 7.x-1.2 on Drupal 7.41. On 2 different content types I've set an address field with help text. Because the website make use of i18 module for the translations, I've enabled it with its submodules. however, the help text is shown only in the default language (English), despite the new translations are shown in the translation Tab in the page where I can manage the field. The label of the address field is instead correctly translated.

Am I missing anything?
Thank you
Kinmen

Comments

kinmen created an issue. See original summary.

tsaks’s picture

I have the exact same problem.
The label is translated but the help text is not translated (Drupal 7.50 and Address Field 7.x-1.2)
Any help would be appreciated.

Thanks,
Tarmo

gurksor’s picture

StatusFileSize
new654 bytes

Not sure if it's perfect, but it works

kinmen’s picture

Thank you!
I've applied the patch, but the help text in the 2nd language is shown in both original and translated language, not only the 2nd one

gurksor’s picture

Strange... on my site it's working as expected.

Are you still using Address field 1.2 and Core 7.41?

Could you show me your patched function?

Sorry that I ask this but are you sure the translation of the text is correct?

kinmen’s picture

Hello. Thanks for your answer
Address Field is 7.x-1.2
Drupal core is 7.43

What do you mean with "are you sure the translation of the text is correct?"

Here is a piece of patched addressfield.module:

if (!empty($instance['description'])) {
      // Checkout panes convert the fieldset into a container, causing
      // #description to not be rendered. Hence, a real element is added and
      // the old #description is removed.
      $element['#description'] = '';
      $instance_current = i18n_string_object_translate('field_instance', $instance);
      $element['element_description'] = array(
        '#markup' =>  $instance_current['description'],
        '#prefix' => '<div class="fieldset-description">',
        '#suffix' => '</div>',
        '#weight' => -999,
      );
    }

    // Generate the address form.
    $context = array(
      'mode' => 'form',
      'field' => $field,
      'instance' => $instance,
      'langcode' => $langcode,
      'delta' => $delta,
    );
    $element += addressfield_generate($address, $settings['format_handlers'], $context);

    // Remove any already saved default value.
    // See addressfield_form_field_ui_field_edit_form_alter() for the reasoning.
    if ($form_state['build_info']['form_id'] == 'field_ui_field_edit_form') {
      $element['#address'] = array('country' => '');
    }
  }

tnx

gurksor’s picture

Hm, I can't see a problem in the code.

With correct translation I mean under admin/config/regional/translate/translate. Maybe you keept the english text by mistake after the translation or is it possible you tried to fix the problem somewhere in a custom module?

kinmen’s picture

StatusFileSize
new9.92 KB

Hello.
To explain it better: the text IS translated with the new text, but when I create a post in a language other than the default, in the address frame shows both the help text strings, the one in the default language and the one translated into the current language. I attach a pic which shows the issue. Under Indirizzo (=address) you can see the help text which is displayed in 2 rows, the translated help in Italian and under it the original English.
The html looks like the following:

<div class="fieldset-wrapper"><div class="fieldset-description">Questo è un campo indirizzo</div><div class="fieldset-description">This is an address field</div>

I don't know why... looks like a double entry somewhere
Thanks
K.

tomrog’s picture

StatusFileSize
new712 bytes

Maybe this patch will be better as it seems the only thing there is to add is usage of t() function

bojanz’s picture

You can't pass variables to t(), Drupal's translation system can't discover them. i18n_string() must be used.

tomrog’s picture

@bojanz good to know :) But to be exact - I can, but I should not use variables in t().

Anyway, patch #3 works for me, so thanks for that ;)

nicola85’s picture

StatusFileSize
new757 bytes
kinmen’s picture

Patch applied, but still have the problem: 2 divs "fieldset-description", one in the translated language and the other in the default English. Cache cleared :-(

Anonymous’s picture

#12 works.

Flush cache and translate from content type > manage fields > address field > edit > translate

Thanks