When nodes are translated via the entity_translation module, the Translate tab isn't showed if the node source language is "Language neutral" (LANGUAGE_NONE, "und").
From the entity_translation_tab_access() code:

  return $enabled && entity_translation_get_handler($entity_type, $entity)->getLanguage() != LANGUAGE_NONE;

So, the node is untranslatable until the source language is set.

However, using the TMGMT, it is possible to translate such nodes.
Shouldn't we modify the tmgmt_entity_get_translatable_entities() function to exclude the LANGUAGE_NONE nodes?

Comments

leksat’s picture

Title: Should the "Language neutral" be translatable via the tmgmt_entity module? » "Language neutral" entities should not be translatable via the tmgmt_entity module
Category: Support request » Bug report

Now I'm 100% sure that this is a bug.

From the entity_translation documentation:

Note that the Translate tab is not available for language-neutral nodes. Before translating such a node, you need to edit it and define a specific node language.

leksat’s picture

Priority: Normal » Major

Changed priority to major.

  1. create a fresh D7 site with two languages: English (default) and German
  2. setup basic_page content type to be translatable with the entity_translation
  3. create a "Language neutral" basic_page
  4. translate it via tmgmt (tmgmt_entity + tmgmt_local_ui) to English

Result:

  1. on the admin/content the node is shown as "Language neutral"
  2. on the node edit form the "Original language" select shows German (why German?..) and the selctbox is disabled
  3. the Translation tab does not appear
  4. there is no way to fix this via UI: you can't change the node language anymore
leksat’s picture

Status: Active » Needs review
StatusFileSize
new1.14 KB

The patch filters out entities with LANGUAGE_NONE source language.

miro_dietiker’s picture

Fully agree with your description, this seems a severe bug.
Please consider: All bugs, especially such major ones, are required to provide test coverage.
:-)

leksat’s picture

Added tests and an additional check in the TMGMTEntitySourcePluginController::getData() method.

The last submitted patch, 5: tmgmt-dont_translate_und_entities-2317891-5-tests_only.patch, failed testing.

  • Berdir committed 7368df0 on 7.x-1.x authored by Leksat
    Issue #2317891 by Leksat: Fixed "Language neutral" entities should not...
berdir’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
Status: Needs review » Patch (to be ported)

Thanks, committed to 7.x-1.x.

miro_dietiker’s picture

Issue tags: +8.x release target
sasanikolic’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new6.53 KB

Ported to 8.x, fixed the link of the source entity and the source entities with undefined source language are not displayed anymore.

berdir’s picture

Status: Needs review » Needs work

Looks good.

There is one thing that I forgot, 8.x also has other special languages that we should exclude. Like LANGCODE_NOT_APPLICABLE. Instead of hardcoding it, I think we should compare it with the languageList() from the language manager, that's the same list as we're using in tmgmt_content_get_translatable_entities().

The at least the list test should then be extend to also include an entity with that language code.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new7.51 KB
new2.98 KB

Excluded the entities with not applicable languages and made the test.

Status: Needs review » Needs work

The last submitted patch, 12: language_neutral_-2317891-12.patch, failed testing.

sasanikolic’s picture

berdir’s picture

+++ b/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php
@@ -64,8 +64,8 @@ class ContentEntitySource extends SourcePluginBase {
-    if (isset($languages[$id])) {
-      throw new TMGMTException(t('Entity %entity could not be translated because its language is not applicable', array('%entity' => $entity->label())));
+    if (!isset($languages[$id])) {
+      throw new TMGMTException(t('Entity %entity could not be translated because the language ' . $entity->language()->getName() . ' is not applicable', array('%entity' => $entity->label())));
     }

You still need to update this to use a @language placeholder.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new13.65 KB
new1.6 KB

Changed the placeholders.

berdir’s picture

Status: Needs review » Needs work
  1. +++ b/sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php
    @@ -57,6 +59,14 @@ class ContentEntitySource extends SourcePluginBase {
    +    if ($entity->language()->getId() == LanguageInterface::LANGCODE_NOT_SPECIFIED) {
    +      throw new TMGMTException(t('Entity %entity could not be translated because it is language neutral', array('%entity' => $entity->language()->getId())));
    +    }
    +    $languages = \Drupal::languageManager()->getLanguages();
    +    $id = $entity->language()->getId();
    +    if (!isset($languages[$id])) {
    +      throw new TMGMTException(t('Entity %entity could not be translated because the language %language is not applicable', array('%entity' => $entity->language()->getId(), '%language' => $entity->language()->getName())));
    +    }
    

    You don't need both conditions here, the first one is a subset of the second and also covered with that (because not specified is not in the list of languages).

    Also, the %entity change in the first message was wrong.

  2. +++ b/sources/content/tmgmt_content.module
    @@ -86,7 +86,7 @@ function tmgmt_content_get_translatable_entities($entity_type_id, $property_cond
     
    -  $langcodes = array_keys(language_list());
    +  $langcodes = array_keys(\Drupal::languageManager()->getLanguages());
       $languages = array_combine($langcodes, $langcodes);
     
    

    Avoid changing existing code that is not really related to an issue. This will actually conflict with #2427153: Replace deprecated calls, but this needs an update anyway.

sasanikolic’s picture

sasanikolic’s picture

Status: Needs work » Needs review

Needs review...

The last submitted patch, 14: language_neutral_-2317891-14.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 18: language_neutral_-2317891-18.patch, failed testing.

sasanikolic’s picture

Status: Needs work » Needs review
StatusFileSize
new6.97 KB
new950 bytes
berdir’s picture

Status: Needs review » Fixed

Committed.

  • Berdir committed d0f0b8e on 8.x-1.x authored by sasanikolic
    Issue #2317891 by sasanikolic, Leksat: "Language neutral" entities...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.