I came across this problem in the Organic Groups module on the configuration page for 'Messaging & Notifications'. The page there is basically a big Drupal form containing various settings. In the code ik looks like this: (I deleted most of the form here and only copied the interesting part)

Array
(
    [og_settings] => Array
        (
             ...
             [notifications] => Array
                (
                    [#type] => fieldset
                    [#title] => Messaging & Notifications
                    [#collapsible] => 1
                    [#collapsed] => 1
                    [og_email_notification_pattern] => Array
                        (
                            [#type] => textfield
                            [#title] => Format of "From:" field
                            [#default_value] => @user_name  <@site_mail>
                            [#description] => Specify the format of the "From:" field on outgoing notifications. Available variables: @user_mail, @user_name, @site_mail, @site_name. Note that the @user_mail token reveals the author's email address. If the admin email examples above appear blank, you need to set your site email in the "Site information" panel.
                        )

                    [og_new_node_subject] => Array
                        (
                            [#type] => textfield
                            [#title] => Nieuw onderwerp
                            [#description] => Subject of notification message for new content. Available variables: @group, !group_url, @type, @site, !content_url, !reply_url, @title, @subject, @node_full, @node_teaser, @username. %subject contains the comment title in the case of a comment but the node title in the case of a new post. @title is always the node title.
                            [#default_value] => @group: '@title' op @site
                        )
                     ...
               )
            ...
        )
)

This array is then processed by the i18n_form_alter_settings(&$form, &$variables) function that - as far as I can tell - just adds the text This is a multilingual variable. to variables that are configured to be multilingual in the $conf['i18n_variables'] array in settings.php.

The entries 'og_email_notification_pattern', 'og_new_node_subject', ... don't get processed by the i18n_form_alter_settings function so the text This is a multilingual variable. is not added.

I have corrected this problem by changing the function from:

/**
 * Check for multilingual variables in form.
 */
function i18n_form_alter_settings(&$form, &$variables) {
  $result = 0;
  foreach (element_children($form) as $field) {
    if (isset($form[$field]['#type']) && $form[$field]['#type'] == 'fieldset') {
      $result += i18n_form_alter_settings($form[$field], $variables);
    }
    elseif (in_array($field, $variables)) {
      $form[$field]['#description'] .= ' <strong>'. t('This is a multilingual variable.') .'</strong>';
      $result++;
    }
  }
  return $result;
}

to:

/**
 * Check for multilingual variables in form.
 */
function i18n_form_alter_settings(&$form, &$variables) {
  $result = 0;
  foreach (element_children($form) as $field) {
    $possible_deeper_children = element_children($form[$field]);
    if (is_array($possible_deeper_children) && !empty($possible_deeper_children)) {
        foreach ($possible_deeper_children as $child) {
            $result += i18n_form_alter_settings($form[$field][$child], $variables);
        }
    }
    if (isset($form[$field]['#type']) && $form[$field]['#type'] == 'fieldset') {
      $result += i18n_form_alter_settings($form[$field], $variables);
    }
    elseif (in_array($field, $variables)) {
      $form[$field]['#description'] .= ' <strong>'. t('This is a multilingual variable.') .'</strong>';
      $result++;
    }
  }
  return $result;
}

This code seems to work very nice but it would be great if someone with more experience on the i18n project could verify the changes.

Comments

jose reyero’s picture

finex’s picture

I've tried this patch, but it doesn't work in my specific case: I'm using the "menu_breadcrumb" module where a nested form is not considered a s multilingual even if the variable name has been set into settings.php (and the localized values are saved in i18n_variable table).

- http://drupal.org/node/400748
- http://drupal.org/node/618700#comment-2530916

finex’s picture

Status: Closed (duplicate) » Active
stewart.adam’s picture

subscribing

jose reyero’s picture

Status: Active » Closed (won't fix)

Cleaning up the issue tracker. Closing all issues that haven't got any follow up for the last year (and are not on RTBC state). Feel free to reopen if you're willing to (really) work on this.