protected function i18n_string_object_wrapper::translate_object in Internationalization 7
Translate all properties for object.
On top of object strings we search for all textgroup:type:objectid:* properties
Parameters
$langcode: A clone of the object or array
1 call to i18n_string_object_wrapper::translate_object()
- i18n_string_object_wrapper::translate in i18n_string/
i18n_string.inc - Translate object.
File
- i18n_string/
i18n_string.inc, line 1279 - API for internationalization strings
Class
- i18n_string_object_wrapper
- String object wrapper
Code
protected function translate_object($langcode, $options) {
// Clone object or array so we don't affect the original one.
$object = is_object($this->object) ? clone $this->object : $this->object;
// Get object strings for translatable properties.
if ($strings = $this
->get_strings()) {
// We preload some of the property translations with a single query.
if ($context = $this
->get_translate_context($langcode, $options)) {
$found = $this
->textgroup()
->multiple_translation_search($context, $langcode);
}
// Replace all strings in object.
foreach ($strings as $i18nstring) {
$this
->translate_field($object, $i18nstring, $langcode, $options);
}
}
return $object;
}