I don't know if this is a bug or a setting that I missed..but here is my issue;

I enabled entity translation for articles.
When i create a new article, I see a language selection dropdown that is shows 'language neutral' by default.
(Would be nice to have the current users language preselected, but thats another issue I guess).

When I select Dutch, fill in title and body and hit save, the article is created, but no language is applied to it, no translation tab is visible.
When I edit that node, I see that the language selection dropdown is still 'language neutral'.
When I select Dutch again, and save, the node is finally showing the translate tab and has content assigned to a language.

What am I missing here?

Comments

plach’s picture

Status: Active » Postponed (maintainer needs more info)

This is not the normal behavior and I've not experienced somehitng like this before. Have you installed any module that might mess with the node language widget?

GN’s picture

It hasn't happened to me before, either, but now I see this problem, too.

  • I create a new node with language set to "English", and save it;
  • However, the node is saved as "Language neutral", so the "Translate" button is not displayed;
  • I need to edit the node and set its language once again to "English", then it can be saved.

I have not installed any new modules, only latest updates (Drupal, Views, Variable, etc.).

fricca’s picture

I think this depends on a setting in i18n/Multilingual Content (/admin/config/regional/i18n/node):
For "Default language for content types with Multilingual support disabled." you have to use the first option "The site's default language (Default behaviour) "
With the second setting "Language neutral (Recommended)" you get the described behaviour.

For i18n, content with entity translation enabled seems to have no "Multilingual support". Which one causes this -- i18n or Entity Translation?

GN’s picture

Yes, you are right, thank you - switching "Default language for content types with Multilingual support disabled" from "Language neutral (Recommended)" to "The site's default language (Default behaviour)" fixes this problem.
Formally, this should not affect entity-translated content types (because their "Multilingual support" setting is not "Disabled", it is "Enabled, with field translation"). But it does.

olafkarsten’s picture

Category: support » bug

I can confirm the issue, but not the "fix". If you change the settings, than the node will saved in the sites default language and not in language neutral. But if you select another language than sites default language in the node creation form, it will be ignored. So the bug is - the language selection on node creation will simple ignored. The saved node will have the language from the default settings (see #3). On node edit form it works.

olafkarsten’s picture

Category: bug » support

I have tried to reproduce this on a fresh drupal install with enabling some of the main modules like entity, i18n, views - but without luck. So I guess it's something in another module.

I'm willing to search further. Any Hints where to start debugging? I have stepped through the node validation process after submitting the node, but didn't find something. (BTW: This is really a crazy experience. ;) )

plach’s picture

First of all I'd try and disable i18n_node to see if the problem is originated by some conflict with it as suggested in #3. If that doesn't work I'd just disable one module at a time and check whether things work properly. This should help to identifiy which module is conflicting with ET.

Yuri’s picture

I have checked this out..disabling modules one by one. In my drupal site I use internationalization and entity translation together. It's an organig groups site, which needs entity translation for the groups (to prevent multiple group id's for the same group). In the meanwhile, group content uses normal node translation. This is the most effective setup for my use case, as far as I know.

It appears that when the module 'multilingual content' is enabled, and a node is created that uses entity translation, the language field is ignored and the translate tab does not appear, just like the current issue describes.

When multilingual content module is disabled, a created node keeps its language setting and shows the translate tab. Hitting the translate tab shows the translation correctly.

Multilingual content is depending on internationalization and string translation, but with those modules enabled and multilingual content disabled, it still works correctly, so those are not causing this issue.

This is as far as my expertise goes, please have a look at this. Thanks.

Yuri’s picture

The multilingual content module does this: http://drupal.org/node/1279644
Not an essential module, but still obvious in most cases (Set current language as default for new content, require language etc.)

olafkarsten’s picture

Yes it is the i18n_node module. I think its _i18n_node_form_node_form_alter, which sets the language to neutral. fricca in #3 is right, with the settings. (I guess I forget a drush cc earlier one). So if you follow fricca's advice in #3, it should work.

Yuri’s picture

Yes, i confirm that #2 works, although that should be a workaround, since many people will encounter this issue.

@olaf in #5 you write "But if you select another language than sites default language in the node creation form, it will be ignored".
I can't reproduce that, in my case also the non-default language set in the node creation form, is creating a translation correctly.

olafkarsten’s picture

Yes #2/3 works. Was an cache issue I guess.

plach’s picture

I suspect this might be fixed by http://drupalcode.org/project/entity_translation.git/tree/refs/heads/7.x... (click the snapshot link to get an installable package): it's the topic branch for #1280546: Introduce a language selection widget for every entity. Backup your site before installing!

bforchhammer’s picture

I think we now have the all features provided by "multilingual content" in ET core (correct my if I'm wrong)... can we close this as "works as designed"?

plach’s picture

Status: Postponed (maintainer needs more info) » Closed (works as designed)

Yes :)

MXT’s picture

Category: support » bug
Status: Closed (works as designed) » Active

I'm very sorry to reopen this, but I'm using last entity_translation 7.x-1.0-beta2 version (2012-Nov-21) and the issue is still present.

Using workaround suggested in #3 all works fine, but:

  1. If #3 is the definitive solution it should be documented somewhere
  2. otherwise we have an interface inconsistency that have to be resolved (de facto setting "default language" to "current language" in "/admin/config/regional/entity_translation" doesn't have any effect IF "Default language for content types with Multilingual support disabled" in /admin/config/regional/i18n/node is setted to "Language neutral (Recommended)"

Thank you very much for considering this.

(please ignore and close this if the issue have been already resolved in latest DEV)

plach’s picture

baso’s picture

Issue summary: View changes

For Content types with option Multilingual support set to 'Disabled' (under Edit » Publishing options), #3 will make new content of these types have a specific language instead of an undefined language. I prefer to have an undefined language.

Furthermore, I understand that module Multilingual select (i18n_select) is incompatible with Entity Translation but I do want to use Multiligual content (i18n_node). See #18 in issue https://www.drupal.org/node/1852102.

To solve these problems, instead of #3 I use the following workaround:

/**
 * Implements hook_form_alter().
 */
function YOUR_MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
  // Append custom handlers.
  if (isset($form['#node_edit_form']) && $form['#node_edit_form'] === TRUE) {
  	// We are in node add/edit mode.
  	if (YOUR_MODULE_NAME_node_type_with_entity_translation($form['#node']->type)) {
      $form['#after_build'][] = '_YOUR_MODULE_NAME_form_node_after_build';
      $form['#submit'][] = '_YOUR_MODULE_NAME_form_node_submit';
	  }
  }
}

/**
 * Custom submit handler.
 */
function _YOUR_MODULE_NAME_form_node_submit(&$form, &$form_state) {
  $node = $form_state['node'];
  // Undo i18n language change.
  if (!i18n_node_type_enabled($node) && variable_get('i18n_node_default_language_none', 0) &&
      !isset($node->nid)) {
    // Add mode. 
    if (isset($form['language']['#value']) && !empty($form['language']['#value'])) {
      $form_state['node']->language = $form['language']['#value'];
      $form_state['values']['language'] = $form['language']['#value'];
    }
  }
}

/**
 * Custom after build handler.
 */
function _YOUR_MODULE_NAME_form_node_after_build(&$form, &$form_state) {
    // Do your extra stuff here, like sorting the language list.
//  // Sort language options list.
//  if (isset($form['language']['#options'])) {
//    // Add/edit mode.
//     natcasesort($form['language']['#options']);
//  }

  // Undo i18n language change.
  $node = $form['#node'];
  if (!i18n_node_type_enabled($node) && variable_get('i18n_node_default_language_none', 0) &&
      !isset($form['#node']->nid)) {
    // Add mode. 
    if (isset($form_state['input']['language']) && !empty($form_state['input']['language'])) {
      $form['language']['#value'] = $form_state['input']['language'];
    }
    else if (!empty($form['language']['#default_value'])) {
      $form['language']['#value'] = $form_state['values']['language'] = $form['language']['#default_value'];
    }
  }

  return $form;
}

/**
 * Check if entity translation is enabled for specified node type.
 *
 * @param $type
 *   Node, node type object, or node type name
 */
function YOUR_MODULE_NAME_node_type_with_entity_translation($type) {
  $type = is_object($type) ? $type->type : $type;
  $mode = variable_get('language_content_type_' . $type, 0);
  return $mode == 4; // 4 == ENTITY_TRANSLATION_ENABLED
}

This also solves issue https://www.drupal.org/node/2301649.

rv0’s picture