function countries_i18n_field_formatter_view in Countries 7.2
Same name and namespace in other branches
- 8 modules/countries_i18n/countries_i18n.module \countries_i18n_field_formatter_view()
Implements hook_field_formatter_view().
File
- modules/
countries_i18n/ countries_i18n.module, line 142 - Provides translation for countries module.
Code
function countries_i18n_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
$settings = $display['settings'];
switch ($display['type']) {
case 'country_default_i18n':
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#markup' => check_plain(countries_i18n_translate($item['iso2'], 'name', $item['safe_value'])),
);
}
break;
case 'country_official_i18n':
foreach ($items as $delta => $item) {
$official_name = isset($item['country']->official_name) ? $item['country']->official_name : $item['safe_value'];
$element[$delta] = array(
'#markup' => check_plain(countries_i18n_translate($item['iso2'], 'official_name', $official_name)),
);
}
break;
}
return $element;
}