You are here

function i18nstrings_translate_object in Internationalization 6

Translate object properties.

File

i18nstrings/i18nstrings.module, line 343
Internationalization (i18n) package - translatable strings.

Code

function i18nstrings_translate_object($context, &$object, $properties = array(), $langcode = NULL) {
  global $language;
  $langcode = $langcode ? $langcode : $language->language;

  // If language is default, just return.
  if (i18nstrings_translate_langcode($langcode)) {
    $context = i18nstrings_context($context);

    // @ TODO Object prefetch
    foreach ($properties as $property) {
      $context->property = $property;
      $context->location = i18nstrings_location($context);
      if (!empty($object->{$property})) {
        $object->{$property} = i18nstrings_translate_string($context, $object->{$property}, $langcode);
      }
    }
  }
}