You are here

function i18n_string_translate_page_object in Internationalization 7

Generate translate page from object.

Parameters

string $object_type: Obejct type as declared in hook_i18n_object_info().

object $object_value: Drupal object to translate.

object $language: Optional language object.

2 calls to i18n_string_translate_page_object()
i18n_field_page_translate in i18n_field/i18n_field.pages.inc
Field translation page
i18n_string_object_translate_page in i18n_string/i18n_string.module
Generic translation page for i18n_strings objects.

File

i18n_string/i18n_string.pages.inc, line 24
Internationalization (i18n) package - translatable strings reusable admin UI.

Code

function i18n_string_translate_page_object($object_type, $object_value, $language = NULL) {

  // For backwards compatibility, ensure parameter is a language object
  $language = i18n_language_object($language);
  $langcode = $language ? $language->language : NULL;

  // Get base keys for all these strings. Object key may be multiple like for blocks (module, delta)
  $object = i18n_object($object_type, $object_value);
  $strings = $object
    ->get_strings(array(
    'empty' => TRUE,
  ));

  // If no localizable strings, print message and fail gracefully.
  // Possibly this object comes from some other contrib module.
  // See http://drupal.org/node/1889878
  if (!$strings) {
    return t('This object has no strings available for translation.');
  }
  if (empty($langcode)) {
    drupal_set_title(t('Translate !name', array(
      '!name' => i18n_object_info($object_type, 'title'),
    )));
    return i18n_string_translate_page_overview($object, $strings);
  }
  else {
    drupal_set_title(t('Translate to !language', array(
      '!language' => i18n_language_name($langcode),
    )));
    return drupal_get_form('i18n_string_translate_page_form', $strings, $langcode);
  }
}