translatable, translation enabled, multilingual, language-aware, language-alterable

Created on 1 May 2013, over 11 years ago
Updated 24 April 2023, over 1 year ago

Follow up for #1977784: Content language settings configuration page needs to determine what entities and bundles to include

Problem/Motivation

confusing terms: translatable, multilingual, language-aware, untranslatable, non-translatable, not translatable, enable translation, translation enabled/disabled/not enabled
It's confusing in code, code comments, and UI

UI

In the UI, to enable translation, the checkboxes usually are for making it "translatable".

  • admin/structure/types/manage/article/fields/node.article.field_image where parts of the image field can be checked off to be "Translatable elements"
  • admin/config/regional/content-language content language settings page where the header to the column is "translatable"
  • admin/structure/types/manage/article where Translation is "Enable translation"
  • admin/structure/types/manage/article/fields/node.article.body/field-settings is "Users may translate this field."

code and the code comments

the translatable setting is really (imo) whether translation is enabled
and that is set only when something is translatable. things that are not translatable do not have 'translatable' set either way.

core/lib/Drupal/Core/Entity/Annotation/EntityType.php

  /**
   * Boolean indicating whether entities of this type have multilingual support.
   *
   * At an entity level, this indicates language support and at a bundle level
   * this indicates translation support.
   *
   * @var bool (optional)
   */
  public $translatable = FALSE;

core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php

/**
 * Defines the node entity class.
 *
 * @EntityType(
 *   id = "node",
 *   label = @Translation("Content"),
 *   bundle_label = @Translation("Content type"),
 *   module = "node",
 *   controllers = {
 *     "storage" = "Drupal\node\NodeStorageController",
 *     "render" = "Drupal\node\NodeRenderController",
 *     "access" = "Drupal\node\NodeAccessController",
 *     "form" = {
 *       "default" = "Drupal\node\NodeFormController"
 *     },
 *     "translation" = "Drupal\node\NodeTranslationController"
 *   },
 *   base_table = "node",
 *   revision_table = "node_revision",
 *   uri_callback = "node_uri",
 *   fieldable = TRUE,
 *   translatable = TRUE,

core/modules/language/language.module

/**
 * Returns a list of supported entity types.
 *
 * @return array
 *   An array of entity type names.
 */
function language_entity_supported() {
  $supported = array();
  foreach (entity_get_info() as $entity_type => $info) {
    if (!empty($info['translatable'])) {
      $supported[$entity_type] = $entity_type;
    }
  }
  return $supported;
}

core/modules/translation_entity/translation_entity.module

function translation_entity_preprocess_language_content_settings_table(&$variables) {
  module_load_include('inc', 'translation_entity', 'translation_entity.admin');
  _translation_entity_preprocess_language_content_settings_table($variables);
}

/**
 * Stores entity translation settings.
 *
 * @param array $settings
 *   An associative array of settings keyed by entity type and bundle. At bundle
 *   level the following keys are available:
 *   - translatable: The bundle translatability status, which is a bool.
 *   - settings: An array of language configuration settings as defined by
 *     language_save_default_configuration().
 *   - fields: An associative array with field names as keys and a boolean as
 *     value, indicating field translatability.
 *   - columns: An associative array of translation synchronization settings
 *     keyed by field names.
 */
function translation_entity_save_settings($settings) {
  foreach ($settings as $entity_type => $entity_settings) {
    foreach ($entity_settings as $bundle => $bundle_settings) {
      // The 'translatable' value is set only if it is possible to enable.
      if (isset($bundle_settings['translatable'])) {
        // Store whether a bundle has translation enabled or not.
        translation_entity_set_config($entity_type, $bundle, 'enabled', $bundle_settings['translatable']);

(see #1977784: Content language settings configuration page needs to determine what entities and bundles to include also)

core/modules/translation_entity/translation_entity.admin.inc
for example, function _translation_entity_form_language_content_settings_form_alter

Proposed resolution

Remaining tasks

Discuss.
Document.
Discuss if there is a need to make the UI more consistant, if so, open an issue.

User interface changes

TBD

API changes

TBD

Related Issues

📌 Task
Status

Active

Version

10.1

Component
Content translation 

Last updated about 17 hours ago

No maintainer
Created by

🇺🇸United States yesct

Live updates comments and jobs are added and updated live.
  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024