function webform_localization_translate_strings in Webform Localization 7.4
Same name and namespace in other branches
- 7 includes/webform_localization.i18n.inc \webform_localization_translate_strings()
Translate general webform properties.
Parameters
object $node: A node object.
3 calls to webform_localization_translate_strings()
- webform_localization_entitycache_node_load in ./
webform_localization.module - Implements hook_entitycache_node_load().
- webform_localization_i18n_string_refresh in ./
webform_localization.module - Update / create / delete translation source for components.
- webform_localization_node_load in ./
webform_localization.module - Implements hook_node_load().
File
- includes/
webform_localization.i18n.inc, line 350 - Webform Localization i18n_string integration.
Code
function webform_localization_translate_strings(&$node, $update = FALSE) {
$options = array(
'update' => $update,
);
if (!array_key_exists('nid', $node->webform)) {
$node->webform['nid'] = $node->nid;
}
$name = webform_localization_i18n_string_name($node->webform['nid'], 'confirmation');
$confirmationOptions = $options + array(
'format' => I18N_STRING_FILTER_XSS,
);
if (in_array($node->webform['redirect_url'], array(
'<confirmation>',
'<none>',
)) && isset($node->webform['confirmation_format'])) {
if (i18n_string_allowed_format($node->webform['confirmation_format'])) {
$confirmationOptions['format'] = $node->webform['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' => $node->webform['confirmation_format'],
)), 'warning', FALSE);
}
}
$node->webform['confirmation'] = i18n_string($name, $node->webform['confirmation'], $confirmationOptions);
$name = webform_localization_i18n_string_name($node->webform['nid'], 'preview_message');
if (isset($node->webform['preview_message_format'])) {
if (i18n_string_allowed_format($node->webform['preview_message_format'])) {
$confirmationOptions['format'] = $node->webform['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' => $node->webform['preview_message_format'],
)), 'warning', FALSE);
}
}
$node->webform['preview_message'] = i18n_string($name, $node->webform['preview_message'], $confirmationOptions);
$name = webform_localization_i18n_string_name($node->webform['nid'], 'submit_text');
$node->webform['submit_text'] = i18n_string($name, $node->webform['submit_text'], $options);
// Allow to translate the redirect url if it's not set to none or the
// default confirmation page.
if (!in_array($node->webform['redirect_url'], array(
'<confirmation>',
'<none>',
'<front>',
))) {
$name = webform_localization_i18n_string_name($node->webform['nid'], 'redirect_url');
$node->webform['redirect_url'] = i18n_string($name, $node->webform['redirect_url'], $options);
}
}