diff --git a/sources/entity/tmgmt_entity.plugin.inc b/sources/entity/tmgmt_entity.plugin.inc index 5145623..6d0b039 100644 --- a/sources/entity/tmgmt_entity.plugin.inc +++ b/sources/entity/tmgmt_entity.plugin.inc @@ -68,9 +68,12 @@ class TMGMTEntitySourcePluginController extends TMGMTDefaultSourcePluginControll $bundles = tmgmt_entity_get_translatable_bundles($job_item->item_type); $info = entity_get_info($job_item->item_type); list(, , $bundle) = entity_extract_ids($job_item->item_type, $entity); - if (isset($bundles[$bundle])) { + // Display entity type and label if we have one and the bundle isn't + // the same as the entity type. + if (isset($bundles[$bundle]) && $bundle != $job_item->item_type) { return t('@type (@bundle)', array('@type' => $info['label'], '@bundle' => $bundles[$bundle])); } + // Otherwise just display the entity type label. elseif (isset($info['label'])) { return $info['label']; } diff --git a/sources/entity/tmgmt_entity.source.test b/sources/entity/tmgmt_entity.source.test index ecf18f7..3db881b 100644 --- a/sources/entity/tmgmt_entity.source.test +++ b/sources/entity/tmgmt_entity.source.test @@ -41,7 +41,7 @@ class TMGMTEntitySourceTestCase extends TMGMTEntityTestCaseUtility { function testEntitySourceNode() { $this->setEnvironment('de'); - $this->createNodeType('article', st('Article'), ENTITY_TRANSLATION_ENABLED); + $this->createNodeType('article', 'Article', ENTITY_TRANSLATION_ENABLED); // Create a translation job. $job = $this->createJob(); @@ -53,7 +53,8 @@ class TMGMTEntitySourceTestCase extends TMGMTEntityTestCaseUtility { for ($i = 1; $i <= 5; $i++) { $node = $this->createNode('article'); // Create a job item for this node and add it to the job. - $job->addItem('entity', 'node', $node->nid); + $item = $job->addItem('entity', 'node', $node->nid); + $this->assertEqual(t('@type (@bundle)', array('@type' => t('Content'), '@bundle' => 'Article')), $item->getSourceType()); } // Translate the job. @@ -88,7 +89,8 @@ class TMGMTEntitySourceTestCase extends TMGMTEntityTestCaseUtility { for ($i = 1; $i <= 5; $i++) { $term = $this->createTaxonomyTerm($this->vocabulary); // Create the item and assign it to the job. - $job->addItem('entity', 'taxonomy_term', $term->tid); + $item = $job->addItem('entity', 'taxonomy_term', $term->tid); + $this->assertEqual(t('@type (@bundle)', array('@type' => t('Term'), '@bundle' => $this->vocabulary->name)), $item->getSourceType()); } // Request the translation and accept it. $job->requestTranslation(); diff --git a/sources/i18n_string/tmgmt_i18n_string.test b/sources/i18n_string/tmgmt_i18n_string.test index 2fa54fb..9340cb7 100644 --- a/sources/i18n_string/tmgmt_i18n_string.test +++ b/sources/i18n_string/tmgmt_i18n_string.test @@ -46,6 +46,7 @@ class TMGMTI18nStringSourceTestCase extends TMGMTBaseTestCase { $job->save(); $item1 = $job->addItem('i18n_string', 'i18n_string', $string_object_name); + $this->assertEqual(t('Vocabulary'), $item1->getSourceType()); $job->requestTranslation(); foreach ($job->getItems() as $item) { @@ -79,6 +80,7 @@ class TMGMTI18nStringSourceTestCase extends TMGMTBaseTestCase { $job->save(); $item1 = $job->addItem('i18n_string', 'i18n_string', $string_object_name); + $this->assertEqual(t('Term'), $item1->getSourceType()); $job->requestTranslation(); foreach ($job->getItems() as $item) { @@ -97,7 +99,7 @@ class TMGMTI18nStringSourceTestCase extends TMGMTBaseTestCase { } - function NtestI18nStringSourceMenu() { + function testI18nStringSourceMenu() { // Enabling this here as enabling it with tmgmt_ui results in missing views // handlers errors. Not sure why, but this way it at least works. module_enable(array('i18n_menu')); @@ -122,6 +124,7 @@ class TMGMTI18nStringSourceTestCase extends TMGMTBaseTestCase { $job->settings = array(); $item1 = $job->addItem('i18n_string', 'i18n_string', $string_name); + $this->assertEqual(t('Menu'), $item1->getSourceType()); $job->requestTranslation(); foreach ($job->getItems() as $item) { /* @var $item TMGMTJobItem */ @@ -157,6 +160,7 @@ class TMGMTI18nStringSourceTestCase extends TMGMTBaseTestCase { $job->settings = array(); $item1 = $job->addItem('i18n_string', 'i18n_string', $string_name); + $this->assertEqual(t('Menu link'), $item1->getSourceType()); $job->requestTranslation(); foreach ($job->getItems() as $item) { /* @var $item TMGMTJobItem */ diff --git a/sources/node/tmgmt_node.test b/sources/node/tmgmt_node.test index aa05de2..bbd3314 100644 --- a/sources/node/tmgmt_node.test +++ b/sources/node/tmgmt_node.test @@ -27,7 +27,7 @@ class TMGMTNodeSourceTestCase extends TMGMTEntityTestCaseUtility { parent::setUp(array('tmgmt_node', 'translation')); $this->loginAsAdmin(); $this->setEnvironment('de'); - $this->createNodeType('page', st('Basic page'), TRANSLATION_ENABLED, FALSE); + $this->createNodeType('page', 'Basic page', TRANSLATION_ENABLED, FALSE); $this->attachFields('node', 'page', array(TRUE, TRUE, FALSE, FALSE)); } @@ -45,7 +45,8 @@ class TMGMTNodeSourceTestCase extends TMGMTEntityTestCaseUtility { for ($i = 0; $i < 2; $i++) { $node = $this->createNode('page'); // Create a job item for this node and add it to the job. - $job->addItem('node', 'node', $node->nid); + $item = $job->addItem('node', 'node', $node->nid); + $this->assertEqual('Basic page', $item->getSourceType()); } // Translate the job. diff --git a/ui/includes/tmgmt_ui.pages.inc b/ui/includes/tmgmt_ui.pages.inc index 4e65daf..7d8717d 100644 --- a/ui/includes/tmgmt_ui.pages.inc +++ b/ui/includes/tmgmt_ui.pages.inc @@ -628,7 +628,7 @@ function _tmgmt_ui_translation_suggestions(array &$suggestions_table, array &$fo $suggestions_table['#empty'] = t('No related suggestions available.'); $suggestions_table['#header'] = array( 'title' => t('Title'), - 'plugin' => t('Plugin'), + 'plugin' => t('Type'), 'reason' => t('Reason'), 'words' => t('Word count'), ); @@ -648,10 +648,9 @@ function _tmgmt_ui_add_suggestion_item(array $result) { $item = $result['job_item']; $reason = isset($result['reason']) ? $result['reason'] : NULL; - $labels = _tmgmt_plugin_labels('source'); $option = array( 'title' => $item->label(), - 'plugin' => isset($labels[$item->plugin]) ? $labels[$item->plugin] : '', + 'plugin' => $item->getSourceType(), 'words' => $item->getWordCount(), 'reason' => $reason, ); diff --git a/ui/tmgmt_ui.module b/ui/tmgmt_ui.module index 7c67c8e..3102ca5 100644 --- a/ui/tmgmt_ui.module +++ b/ui/tmgmt_ui.module @@ -386,11 +386,10 @@ function tmgmt_ui_translation_review_form_defaults($form, &$form_state, TMGMTJob '#suffix' => '', ); - $source_labels = tmgmt_source_plugin_labels(); $form['info']['sourcetype'] = array( '#type' => 'item', '#title' => t('Source type'), - '#markup' => $source_labels[$item->plugin], + '#markup' => $item->getSourceType(), '#prefix' => '
', '#suffix' => '
', ); diff --git a/ui/views/tmgmt_ui_job_items.view.inc b/ui/views/tmgmt_ui_job_items.view.inc index 947d2d8..99a8db3 100644 --- a/ui/views/tmgmt_ui_job_items.view.inc +++ b/ui/views/tmgmt_ui_job_items.view.inc @@ -70,11 +70,10 @@ $handler->display->display_options['fields']['label']['id'] = 'label'; $handler->display->display_options['fields']['label']['table'] = 'tmgmt_job_item'; $handler->display->display_options['fields']['label']['field'] = 'label'; $handler->display->display_options['fields']['label']['ui_name'] = 'Label'; -/* Field: Plugin */ -$handler->display->display_options['fields']['plugin']['id'] = 'plugin'; -$handler->display->display_options['fields']['plugin']['table'] = 'tmgmt_job_item'; -$handler->display->display_options['fields']['plugin']['field'] = 'plugin'; -$handler->display->display_options['fields']['plugin']['ui_name'] = 'Plugin'; +/* Field: Translation Management Job Item: Type */ +$handler->display->display_options['fields']['type']['id'] = 'type'; +$handler->display->display_options['fields']['type']['table'] = 'tmgmt_job_item'; +$handler->display->display_options['fields']['type']['field'] = 'type'; /* Field: State */ $handler->display->display_options['fields']['state']['id'] = 'state'; $handler->display->display_options['fields']['state']['table'] = 'tmgmt_job_item'; @@ -133,6 +132,9 @@ $handler->display->display_options['fields']['operations']['table'] = 'tmgmt_job $handler->display->display_options['fields']['operations']['field'] = 'operations'; $handler->display->display_options['fields']['operations']['ui_name'] = 'Operations'; $handler->display->display_options['fields']['operations']['element_label_colon'] = FALSE; + +/* Display: Block */ +$handler = $view->new_display('block', 'Block', 'block'); $translatables['tmgmt_ui_job_items'] = array( t('Master'), t('Job Items'), @@ -151,7 +153,7 @@ $translatables['tmgmt_ui_job_items'] = array( t('last ยป'), t('There are no items attached to this translation job.'), t('Label'), - t('Plugin'), + t('Type'), t('State'), t('Progress'), t('Word count'), @@ -161,5 +163,5 @@ $translatables['tmgmt_ui_job_items'] = array( t('Operations'), t('All'), t('Submit list'), - t('Type'), + t('Block'), );