Hi all,

I set all my content types for entity translation (and all was well), but now have found that some content types would do better to be 'content translated'.

So I deleted all the content for those types, changed the translation setting to 'enable translation' for the content type and start readding content.

When I translated a node, I got redirected to the translated node and an error of 'English translation unavailable for ..' for my translated content. I then looked in the ET table and found the node Ids in there. When I deleted the ids from the table, it was all working fine.

So I thought that maybe this just happens for a content type that gets switched from 'ET' to 'content', so I created a new content type in case just to test. Turns out the same problem happened and the nodes are found in the entity_translation table. Again when I manually deleted the node ids from the table, all was fine.

Hope this helps people out.

Thanks.

Comments

farse’s picture

I don't know if this makes any difference, I have the 'body' field set as translateable through other content types, so when I set a new content type to 'enable translation' (content trans) and when I looked at the body field, under 'body field settings' it says 'Field translation: Users may translate this field. Disable translation'. so I don't know if this has something to do with making the node id go into the entity_translation table without enabling field translation on the content type.

farse’s picture

Priority: Normal » Major
farse’s picture

Also, when checking in Config > entity translation, the content types do not show up indicating that they shouldn't be entity translated.

have been looking around the ET module, but am still getting used to the way drupal modules are constructed so haven't gotten very far.

the only things that have caught my eye are
line 80 in entity_translation.node.inc

/**
 * Returns whether the given node type has support for translations.
 *
 * @return
 *   Boolean value.
 */
function entity_translation_node_supported_type($type) {
  return variable_get('language_content_type_' . $type, 0) == ENTITY_TRANSLATION_ENABLED;
}

with a reference to it in entity_translation.module at line 65

 /**
 * Implements hook_entity_info().
 */
function entity_translation_entity_info() {
  $info = array();

  $info['node'] = array(
    'translation' => array(
      'entity_translation' => array(
        'class' => 'EntityTranslationNodeHandler',
        'access callback' => 'entity_translation_node_tab_access',
        'access arguments' => array(1),
        'admin theme' => variable_get('node_admin_theme'),
        'bundle callback' => 'entity_translation_node_supported_type',
        'default settings' => array(
          'default_language' => LANGUAGE_NONE,
          'hide_language_selector' => FALSE,
        ),
      ),
    ),
  );

farse’s picture

This actually seems to be the bit that inserts the nid into entity_translation (saveTranslations). Seems that it doesn't distinguish itself between different entity types (ie. nodes, taxonomy, users). If there was a way to then check if the bundle is translatable, I would think this would solve the issue?

/**
 * Implements hook_field_attach_insert().
 */
function entity_translation_field_attach_insert($entity_type, $entity) {
  if (entity_translation_enabled($entity_type)) {
    $handler = entity_translation_get_handler($entity_type, $entity);
    $handler->initTranslations();
    $handler->saveTranslations();
  }
}
farse’s picture

referring to my comment#4 i made an amendment that I think prevents putting the node id in the entity_translation table if the bundle is not entity translatable. this is my first ever drupal patch, so any constructive comments would be appreciated if I have done it wrong.

thanks

plach’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Active » Needs review

Let's see what the bost thinks about this.

Status: Needs review » Needs work

The last submitted patch, entity_translation-bundle_translate_check-1835578-5.module.patch, failed testing.

farse’s picture

is this because I made the patch wrong? or was the code bad?

do I have to pull on the latest dev version and then make the patch from that?

plach’s picture

Yes, the patch should be rolled against the latest dev code. A quick code review:

+++ b/sites/all/modules/entity_translation/entity_translation.module
@@ -1075,10 +1078,14 @@ function entity_translation_sync($entity_type, $entity) {
+  if (entity_translation_enabled($entity_type)) {    ¶
+    list(, , $bundle) = entity_extract_ids($entity_type, $entity);   ¶
+    //if bundle is entity translateable, continue
+    if(entity_translation_enabled_bundle($entity_type, $bundle)) {     ¶

You have trailing whitespaces here.

+++ b/sites/all/modules/entity_translation/entity_translation.module
@@ -1075,10 +1078,14 @@ function entity_translation_sync($entity_type, $entity) {
+    //if bundle is entity translateable, continue

@@ -1087,9 +1094,13 @@ function entity_translation_field_attach_insert($entity_type, $entity) {
+    //if bundle is entity translateable, continue

Comments should start with a capital letter and end with a trailing dot, see the coding standard documentation. Also I'd change this to:

Store entity translation metadata only if the entity bundle is translatable.
farse’s picture

thanks for the comments, will do.

plach’s picture

+++ b/sites/all/modules/entity_translation/entity_translation.module
@@ -1075,10 +1078,14 @@ function entity_translation_sync($entity_type, $entity) {
+    if(entity_translation_enabled_bundle($entity_type, $bundle)) {     ¶

@@ -1087,9 +1094,13 @@ function entity_translation_field_attach_insert($entity_type, $entity) {
+    if(entity_translation_enabled_bundle($entity_type, $bundle)) {

Another minor nitpick: there's a missing space after the if.

farse’s picture

Status: Needs work » Needs review
StatusFileSize
new1.62 KB

ok, cloned from current dev version and made suggested changes. let's try this again.

Status: Needs review » Needs work
farse’s picture

Status: Needs work » Needs review
StatusFileSize
new1.62 KB

Status: Needs review » Needs work
plach’s picture

Title: converting content type from 'entity' to 'content' translation causes node id to still go into entity translation table » Entity translation metadata should be stored only if the entity bundle is translatable
Status: Needs work » Reviewed & tested by the community
StatusFileSize
new1.64 KB
new3.4 KB
+++ b/entity_translation.module
@@ -1076,9 +1076,13 @@ function entity_translation_sync($entity_type, $entity) {
+    //Store entity translation metadata only if the entity bundle is translatable.

@@ -1087,9 +1091,13 @@ function entity_translation_field_attach_insert($entity_type, $entity) {
+    //Store entity translation metadata only if the entity bundle is translatable.

Some coding standard quirks here.

+++ b/entity_translation.module
@@ -1087,9 +1091,13 @@ function entity_translation_field_attach_insert($entity_type, $entity) {
+      $handler = entity_translation_get_handler($entity_type, $entity);
+      $handler->initTranslations();

These lines were erroneously copied.

plach’s picture

Please disregard work.patch, I didn't mean to upload it.

bforchhammer’s picture

Status: Reviewed & tested by the community » Fixed

Thanks, committed and pushed :)

farse’s picture

Thanks for helping with the patch. Didn't really know how to progress from my last failed one, but looking at the differences, what exactly was causing it to fail so badlly? The only difference i saw was that the comment was continued on a second line... ?

plach’s picture

You copied the body of the insert hook implementation into the body of the update one:

+      $handler = entity_translation_get_handler($entity_type, $entity);
+      $handler->initTranslations();
+      $handler->saveTranslations();

instead of:

+      $handler = entity_translation_get_handler($entity_type, $entity, TRUE);
+      $handler->updateTranslations();
+      $handler->saveTranslations();

This broke translation editing :)

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

grammar

  • Commit a2ef80c on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions authored by plach, committed by bforchhammer:
    Issue #1835578 by farse, plach: Fixed Entity translation metadata should...

  • Commit a2ef80c on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench authored by plach, committed by bforchhammer:
    Issue #1835578 by farse, plach: Fixed Entity translation metadata should...