function i18n_string_translate_page_form_submit in Internationalization 7
Form submission callback for in-place string translation.
1 string reference to 'i18n_string_translate_page_form_submit'
- i18n_string_translate_page_form_base in i18n_string/
i18n_string.pages.inc - Create base form for string translation
File
- i18n_string/
i18n_string.pages.inc, line 230 - Internationalization (i18n) package - translatable strings reusable admin UI.
Code
function i18n_string_translate_page_form_submit($form, &$form_state) {
$count = $success = 0;
foreach ($form_state['values']['strings'] as $name => $value) {
$count++;
list($textgroup, $context) = i18n_string_context(explode(':', $name));
if (is_array($value)) {
if (isset($value['value'])) {
$value = $value['value'];
$form_state['values']['strings'][$name] = $value;
}
else {
form_set_error("strings][{$name}", t('Unable to get the translated string value.'));
watchdog('locale', 'Unable to get the translated string value, string array is: %string', array(
'%string' => var_dump($value),
), WATCHDOG_WARNING);
}
}
$result = i18n_string_textgroup($textgroup)
->update_translation($context, $form_state['values']['langcode'], $value);
$success += $result ? 1 : 0;
}
if ($success) {
drupal_set_message(format_plural($success, 'A translation was saved successfully.', '@count translations were saved successfully.'));
}
if ($error = $count - $success) {
drupal_set_message(format_plural($error, 'A translation could not be saved.', '@count translations could not be saved.'), 'warning');
}
if (isset($form['#redirect'])) {
$form_state['redirect'] = $form['#redirect'];
}
}