You are here

protected function i18n_string_object_wrapper::translate_field in Internationalization 7

Translate object property.

Mot often, this is a direct field set, but sometimes fields may have different formats.

3 calls to i18n_string_object_wrapper::translate_field()
i18n_field::translate_field in i18n_field/i18n_field.inc
Set field translation for object.
i18n_field_instance::translate_field in i18n_field/i18n_field.inc
Set field translation for object.
i18n_string_object_wrapper::translate_object in i18n_string/i18n_string.inc
Translate all properties for object.
2 methods override i18n_string_object_wrapper::translate_field()
i18n_field::translate_field in i18n_field/i18n_field.inc
Set field translation for object.
i18n_field_instance::translate_field in i18n_field/i18n_field.inc
Set field translation for object.

File

i18n_string/i18n_string.inc, line 1311
API for internationalization strings

Class

i18n_string_object_wrapper
String object wrapper

Code

protected function translate_field(&$object, $i18nstring, $langcode, $options) {
  $field_name = $i18nstring->property;
  $translation = $i18nstring
    ->format_translation($langcode, $options);
  if (is_object($object)) {
    $object->{$field_name} = $translation;
  }
  elseif (is_array($object)) {
    $object[$field_name] = $translation;
  }
}