You are here

function webform_localization_update_translation_strings in Webform Localization 7.4

Same name and namespace in other branches
  1. 7 includes/webform_localization.i18n.inc \webform_localization_update_translation_strings()

Update / create translation source for general webform properties.

Parameters

array $properties: The form_state values that have been saved.

1 call to webform_localization_update_translation_strings()
_webform_localization_webform_configure_form_submit in ./webform_localization.module
Handle specific localization options in Webform Configure Form.

File

includes/webform_localization.i18n.inc, line 295
Webform Localization i18n_string integration.

Code

function webform_localization_update_translation_strings($properties) {
  $options = array(
    'update' => TRUE,
    'translate' => FALSE,
  );
  if (!empty($properties['confirmation']['value'])) {
    $name = webform_localization_i18n_string_name($properties['nid'], 'confirmation');
    $confirmationOptions = $options + array(
      'format' => I18N_STRING_FILTER_XSS,
    );
    if (isset($properties['confirmation']['format'])) {
      if (i18n_string_allowed_format($properties['confirmation']['format'])) {
        $confirmationOptions['format'] = $properties['confirmation']['format'];
      }
      else {
        drupal_set_message(t('The string @name could not be refreshed with the text format @format because it is not allowed for translation.', array(
          '@name' => $name,
          '@format' => $properties['confirmation']['format'],
        )), 'warning', FALSE);
      }
    }
    i18n_string($name, $properties['confirmation']['value'], $confirmationOptions);
  }
  if (!empty($properties['preview_message']['value'])) {
    $name = webform_localization_i18n_string_name($properties['nid'], 'preview_message');
    $confirmationOptions = $options + array(
      'format' => I18N_STRING_FILTER_XSS,
    );
    if (isset($properties['preview_message']['format'])) {
      if (i18n_string_allowed_format($properties['preview_message']['format'])) {
        $confirmationOptions['format'] = $properties['preview_message']['format'];
      }
      else {
        drupal_set_message(t('The string @name could not be refreshed with the text format @format because it is not allowed for translation.', array(
          '@name' => $name,
          '@format' => $properties['preview_message']['format'],
        )), 'warning', FALSE);
      }
    }
    i18n_string($name, $properties['preview_message']['value'], $confirmationOptions);
  }
  if (!empty($properties['submit_text'])) {
    $name = webform_localization_i18n_string_name($properties['nid'], 'submit_text');
    i18n_string($name, $properties['submit_text'], $options);
  }

  // Allow to translate the redirect url if it's not set to none or the
  // default confirmation page.
  if (!in_array($properties['redirect_url'], array(
    '<confirmation>',
    '<none>',
    '<front>',
  ))) {
    $name = webform_localization_i18n_string_name($properties['nid'], 'redirect_url');
    i18n_string($name, $properties['redirect_url'], $options);
  }
}