diff --git a/includes/MediaEntityTranslationHandler.inc b/includes/MediaEntityTranslationHandler.inc new file mode 100644 index 0000000..06ae328 --- /dev/null +++ b/includes/MediaEntityTranslationHandler.inc @@ -0,0 +1,61 @@ +getPathScheme() == 'media') { + $translations = $this->getTranslations(); + $form_langcode = $this->getFormLanguage(); + $source_langcode = $this->getSourceLanguage(); + + $form['source_language']['#access'] = FALSE; + if (empty($source_langcode)) { + $source_langcode = $form_langcode; + $form['actions']['delete_translation']['#access'] = FALSE; + } + + $links = array(); + foreach (entity_translation_languages($this->entityType, $this->entity) as $langcode => $language) { + if (!isset($translations->data[$langcode])) { + $name = t($language->name); + $translation = $langcode == $form_langcode ? $name : l($name, $this->getEditPath() . '/add/' . $source_langcode . '/' . $langcode, array('attributes' => array('class' => array('ctools-use-modal')))); + $links[$langcode] = array( + '#markup' => '' . $translation . ' ', + ); + } + } + + if (!empty($links)) { + $form['media_add_translation'] = array( + '#type' => 'fieldset', + '#title' => t('Add translation'), + '#collapsible' => TRUE, + '#collapsed' => !$this->getSourceLanguage(), + '#weight' => -110, + ) + $links; + } + } + } +} diff --git a/media.info b/media.info index 8cba8d3..ad5bf37 100644 --- a/media.info +++ b/media.info @@ -10,6 +10,7 @@ files[] = includes/MediaBrowserPluginInterface.inc files[] = includes/MediaBrowserPlugin.inc files[] = includes/MediaBrowserUpload.inc files[] = includes/MediaBrowserView.inc +files[] = includes/MediaEntityTranslationHandler.inc files[] = includes/media_views_plugin_display_media_browser.inc files[] = includes/media_views_plugin_style_media_browser.inc files[] = tests/media.test diff --git a/media.module b/media.module index 4ef9f00..339fe43 100644 --- a/media.module +++ b/media.module @@ -85,6 +85,11 @@ function media_entity_info_alter(&$entity_info) { $entity_info['file']['view modes']['media_small'] = array('label' => t('Small'), 'custom settings' => TRUE); $entity_info['file']['view modes']['media_large'] = array('label' => t('Large'), 'custom settings' => TRUE); $entity_info['file']['view modes']['media_original'] = array('label' => t('Original'), 'custom settings' => TRUE); + + if (module_exists('entity_translation')) { + $entity_info['file']['translation']['entity_translation']['class'] = 'MediaEntityTranslationHandler'; + $entity_info['file']['translation']['entity_translation']['path schemes']['media'] = array('edit path' => 'media/%file/edit/%ctools_js'); + } } /**