When creating a new translation, the default language (which is a disabled field) is being set to the original language of the node.

Also when editing an existing translation of a node, the language of the translation is being omitted from the language list.

I will upload a patch for this shortly.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

khaled.zaidan’s picture

Status: Active » Needs review
FileSize
2.03 KB

Here is a patch to fix the issue.

I did some testing on a clean installation and it seems to work correctly.

But I would still love if someone else could give it a quick look.

Status: Needs review » Needs work

The last submitted patch, entity_translation-language_field-1701460-1.patch, failed testing.

khaled.zaidan’s picture

OK last patch failed to be applied. Here's another try.

khaled.zaidan’s picture

Status: Needs work » Needs review

Changing status to 'needs review'.

issa.haddadin’s picture

Status: Needs review » Closed (fixed)

Thank you! it worked with me and all good.

khaled.zaidan’s picture

Status: Closed (fixed) » Reviewed & tested by the community

Issue shouldn't be marked as closed/fixed yet :)

Wait until the fix is committed, otherwise nobody will ever see this ;)

plach’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/entity_translation.module
@@ -152,6 +152,8 @@ function entity_translation_entity_info_alter(&$entity_info) {
+      // Add 'language' entity key to make sure the entity is saved with the correct source language
+      $entity_info[$entity_type]['entity keys']['language'] = 'language';

This is not something I'm inclined to do, because not every entity has a language property. Why is this needed here?

+++ b/includes/translation.handler.inc
@@ -742,8 +742,8 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa
-        $form['language']['#options'][$langcode] = $languages[$langcode]->name;
-        $form['language']['#default_value'] = $langcode;
+        $form['language']['#options'][$form_langcode] = $languages[$form_langcode]->name;
+        $form['language']['#default_value'] = $form_langcode;

This is changing the original entity language, many things would be screwed by this I think.

Instead I think we need a copy of the language widget, something like:

<?php
$form['form_language'] = $form['language'];
$form['form_language']['#default_value'] = $form_langcode;
$form['language'] = array(
  '#type' => 'value',
  '#value' => $langcode,
);
?>
bforchhammer’s picture

Status: Needs work » Needs review
FileSize
1.38 KB

Here's a patch based on the plach's suggestion in #8.

plach’s picture

Status: Needs review » Needs work

If we want to support also changing the translation language we need an active language selector. However it's not clear from the UX folks which direction is the desired one.

bforchhammer’s picture

Right, patch above only fixes the issue with the disabled language dropdown being confusing...

@plach do you think we can postpone the feature for changing the translation language, and go ahead with fixing the current issue? I'd also be happy with removing the dropdown completely, but I remember reading somewhere that it has to stay (I don't remember why).

plach’s picture

I think there is a value in having the entity language always shown for information, but it should be labelled as such. If we want to change the translation language the selector has to be active. The patch in #8 does not improve UX in any of the two directions IMHO.

EDIT: As a stop gap I'd just rename the "Language" label to something like "Original language".

bforchhammer’s picture

Status: Needs work » Needs review
FileSize
689 bytes

Okay, so shall we just adjust the title for now?

plach’s picture

Status: Needs review » Reviewed & tested by the community

Yep, let's leave this open after commit for future improvements if we decide to make the translation language changeable.

bforchhammer’s picture

Title: Incorrect default language when creating/editing a translation » Make translation language changeable
Status: Reviewed & tested by the community » Active

Committed #12. Back to Active.

plach’s picture

Category: bug » feature
plach’s picture

Status: Active » Postponed

Actually this is postponed to the discussion in #1282018: Improve UX of language-aware entity forms.

  • Commit 46c24bd on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions by bforchhammer:
    #1701460 by bforchhammer: Fixed title of original language dropdown.
    

  • Commit 46c24bd on 7.x-1.x, et-permissions-1829630, factory, et-fc, revisions, workbench by bforchhammer:
    #1701460 by bforchhammer: Fixed title of original language dropdown.