You are here

function _i18nviews_localize_array in Internationalization Views 6.2

Translate a group of fields.

We get the translated fields out of the array so they are not translated again.

2 calls to _i18nviews_localize_array()
i18nviews_locale_refresh in ./i18nviews.module
Refresh views locales, 2.x version
i18nviews_views_pre_view in ./i18nviews.module
Implementation of hook_views_pre_view().

File

./i18nviews.module, line 154
Views support for Internationalization (i18n) package

Code

function _i18nviews_localize_array($name, $group, &$data, $field_names, $update = FALSE) {
  $translated = array();
  foreach ($field_names as $field) {
    if (!empty($data[$field])) {
      if ($update) {
        $format = isset($data[$field . '_format']) ? $data[$field . '_format'] : NULL;
        i18nstrings_update("views:{$name}:{$group}:{$field}", $data[$field], $format);
      }
      else {
        $data[$field] = i18nstrings("views:{$name}:{$group}:{$field}", $data[$field]);
        $translated[] = $field;
      }
    }
  }

  // Return remaining field names
  return array_diff($field_names, $translated);
}