Commit 5ffcd1b9 authored by Léo Prada's avatar Léo Prada Committed by Joseph Olstad
Browse files

Issue #2097261 by dafeder, Ludo.R, stefan.r, Nixou, Dave Reid, Leksat,...

Issue #2097261 by dafeder, Ludo.R, stefan.r, Nixou, Dave Reid, Leksat, rodrigoaguilera, stijndmd: Make download links translatable
parent 4c865397
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -437,10 +437,17 @@ function file_entity_field_formatter_view($entity_type, $entity, $field, $instan
          if (isset($item['description'])) {
            $file->description = $item['description'];
          }

          $text = $settings['text'];
          if (module_exists('i18n_string')) {
            $key = 'file_entity:file_download_link:' . $entity_type . ':' . $instance['bundle'] . ':link_text:' . $text;
            $text = i18n_string($key, $text);
          }

          $element[$delta] = array(
            '#theme' => 'file_entity_download_link',
            '#file' => $file,
            '#text' => $settings['text'],
            '#text' => $text,
          );
        }
      }

file_entity.i18n.inc

0 → 100644
+40 −0
Original line number Diff line number Diff line
<?php

/**
 * Implements hook_i18n_string_info().
 */
function file_entity_i18n_string_info() {
  $groups['file_entity'] = array(
    'title' => t('File Entity'),
    'format' => FALSE,
  );
  return $groups;
}

/**
 * Implements hook_i18n_string_list().
 */
function file_entity_i18n_string_list($group) {
  if ($group == 'file_entity') {
    $fields = field_info_instances();

    $strings = array();
    foreach ($fields as $entity_type => $bundles) {
      foreach ($bundles as $bundle => $fields) {
        foreach ($fields as $field_key => $field_settings) {
          foreach ($field_settings['display'] as $view_mode => $view_mode_settings) {
            if (!empty($view_mode_settings['type']) && $view_mode_settings['type'] == 'file_download_link') {
              $text = $view_mode_settings['settings']['text'];

              $key = $entity_type . ':' . $bundle . ':' . 'link_text';

              $strings['file_entity']['file_download_link'][$key][$text] = $text;
            }
          }
        }
      }
    }

    return $strings;
  }
}