function translation_entity_enabled

Determines whether the given entity type is translatable.

@returns TRUE if the specified bundle is translatable. If no bundle is provided returns TRUE if at least one of the entity bundles is translatable.

Parameters

string $entity_type: The type of the entity.

string $bundle: (optional) The bundle of the entity. If no bundle is provided, all the available bundles are checked.

10 calls to translation_entity_enabled()
EntityTranslationSettingsTest::assertSettings in drupal/core/modules/translation_entity/lib/Drupal/translation_entity/Tests/EntityTranslationSettingsTest.php
Asserts that translatability has the expected value for the given bundle.
translation_entity_entity_load in drupal/core/modules/translation_entity/translation_entity.module
Implements hook_entity_load().
translation_entity_field_extra_fields in drupal/core/modules/translation_entity/translation_entity.module
Implements hook_field_extra_fields().
translation_entity_language_configuration_element_process in drupal/core/modules/translation_entity/translation_entity.module
Process callback: Expands the language_configuration form element.
translation_entity_language_configuration_element_submit in drupal/core/modules/translation_entity/translation_entity.module
Form submission handler for element added with translation_entity_language_configuration_element_process().

... See full list

File

drupal/core/modules/translation_entity/translation_entity.module, line 451
Allows entities to be translated into different languages.

Code

function translation_entity_enabled($entity_type, $bundle = NULL) {
  $enabled = FALSE;
  $info = entity_get_info($entity_type);
  if (!empty($info['translatable'])) {
    $bundles = !empty($bundle) ? array(
      $bundle,
    ) : array_keys(entity_get_bundles($entity_type));
    foreach ($bundles as $bundle) {
      if (translation_entity_get_config($entity_type, $bundle, 'enabled')) {
        $enabled = TRUE;
        break;
      }
    }
  }
  return $enabled;
}