Opening a specific node for editing from admin/content list, incorrectly imposes currently negotiated language.
If your current path is /en/admin/content and you try to open node/123 which is in German, the English member of translation set will open anyway and you need to click into translation tab and then into desired language.
That's too much click-consuming.

CommentFileSizeAuthor
#7 i18n_adminfix.zip1.02 KBcrispynewt
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

thelmer’s picture

This one would be nice to have solved.

Content editors don't understand why it's important to have their current language set to the same as the translation they are editing.

Some of the things that will go wrong are node references and menu items (1)

1) http://eureka.ykyuen.info/2013/02/28/drupal-7-menu-item-is-disabled-afte...

ZikPhil’s picture

Hi,

I am still getting this error at the moment. Can we get an update on the status?

crispynewt’s picture

Issue summary: View changes

Hi,

I'm also having this issue and it's causing major problems when the node has term reference or entity reference fields as the values displayed are in the wrong language.

Can you let us know if there's a workaround?

ZikPhil’s picture

That is a workaround, to be added into the theme 'Seven' or whatever admin theme you are running with. It changes every edit link and replace the url lang with the right one. Still it would be nice to have a core-fix :)

jQuery(document).ready(function ($) { 
  if($('body').hasClass('page-admin-content')) {
    $('.edit a').each(function (data, data2) {  
      if($('body').hasClass('i18n-en')) {
        if($(this).parent().parent().parent().parent().find('td:nth-child(7)').html() == "French") {
          var link = $(this).attr('href').replace('en/', 'fr/');
          $(this).attr('href', link);
        }
      }
      if($('body').hasClass('i18n-fr')) {
        if($(this).parent().parent().parent().parent().find('td:nth-child(7)').html() == "Anglais") {
          var link = $(this).attr('href').replace('fr/', 'en/');
          $(this).attr('href', link);
        }        
      }
    });
  };  
});
alberto56’s picture

I can't reproduce this problem on my site. Can someone who is experiencing this please post a screenshot of what they see on admin/config/regional/language/configure?

GeDu’s picture

Thanks, ZikPhil for the solution. It's a very dirty solution but works. alberto56 see image here: img . I tried changing these settings on this page but nothing helped.

crispynewt’s picture

FileSize
1.02 KB

Firstly, thanks for the workaround ZikPhil and apologies for not acknowledging your help sooner... much appreciated!
I managed to adapt this into a quick and dirty temporary solution but now that my client is adding a number of additional languages this isn't a feasible solution any more.

I've now taken a different approach and have implemented a custom module which uses hook_form_alter to loop through all nodes in the admin content listing and rewrites the edit operation if the language of the node is different from the current language.

This should work whether the site is configured to determine the language using the path prefix or domain.

In place of a core fix, I hope this saves someone else some time with this issue.

function i18n_adminfix_form_alter(&$form, $form_state, $form_id) {
    if ($form_id == 'node_admin_content') {
    	global $language;
    	
        foreach ($form['admin']['nodes']['#options'] as &$node) {
        	
        	if (!empty($node['title']['data']['#options']['language'])) {
        		
	        	$node_language = $node['title']['data']['#options']['language'];
				if ($node_language->language != $language->language) {
					
					if ($node_language->prefix != '') {
						$node['operations']['data']['#links']['edit']['href'] = $node_language->prefix.'/'.$node['operations']['data']['#links']['edit']['href'];
					}
					else {
						$node['operations']['data']['#links']['edit']['href'] = get_protocol().$node_language->domain.'/'.$node['operations']['data']['#links']['edit']['href'];
					}
				}
        	}
        }
    }
}

function get_protocol() {
	return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
}
kumkum29’s picture

Hello,

i have the same problem in my site (en/fr).
In the admin content page, i uses view to display the table of the nodes. So, the previous methods seems not to be functionals.

I have created a custom field template for this admin view and insert this code:

<?php
	// Define the site url
	global $base_url;
	// Get the node language
	$node_language = $row->node_language;
        // Get the node id
	$node_id = $row->nid;
?>
<a href="<?php print $base_url; ?>/<?php print $node_language; ?>/node/<?php print $node_id; ?>/edit?destination=admin/content"><?php print t("edit"); ?></a>

It's ok, but for me it's a dirty solution, because in the page of translation, i get the same problem.

In several posts we have this problem. But no good solution is proposed. (https://www.drupal.org/node/1905268...)

pinoniq’s picture

I fixed this issue with a small hook:

/**
 * Implements hook_form_node_admin_content_alter
 */
function MODULENAME_form_node_admin_content_alter(&$form, &$form_state, $form_id) {
  foreach ($form['admin']['nodes']['#options'] as &$option) {
    //foreach link, add the language
    foreach ($option['operations']['data']['#links'] as &$link) {
      //Copy the language from the Title. This should however not be needed...
      $link['language'] = $option['title']['data']['#options']['language'];
    }
  }
}

This shoud however be done in i18n

pinoniq’s picture

Version: 7.x-1.8 » 7.x-1.12
Component: Node » Menus
Priority: Normal » Major
Jose Reyero’s picture

Priority: Major » Normal

Resetting priority.

dparvanov’s picture

Hi everyone.

Firstly thanks to pinoniq for the working solution.

I have however same problem with links in translation overview page.

When content is in untraslated status links are working and translation nodes are created.
But when translation is in status complete link only open edit form for the current language.

Can you help me made a solution for this as well...

Update...issue was due to Translation overview module overriding the links. Deactivating the module seems to fix the problem.

pwiniacki’s picture

I can confirm this issue - very frustrating. Definitely MAJOR one, cause you have a lot of work after editing node in a wrong language cause of taxonomy dependents (witch are working wrong...).

matthieu_collet’s picture

yes major issue for me too,

it's impossible to do correct translations without changing the language of the page itself, we completely loose node reference synchronisation :(

and js hack doesn't work in the pages I need

module at #9 works in the all content page, thank you ! I try now to adaot it also at another important page, all the "node/NID/translate" pages

matthieu_collet’s picture

in fact, we can correct the function i18n_node_translation_link

bug is there I think, I added

if (empty($options))
	{
	$installed_languages = language_list();
	$language = $installed_languages[$langcode];
	$options['language'] = $language;
	}
function i18n_node_translation_link($text, $path, $langcode, $options = array()) {
  $type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
  $links = language_negotiation_get_switch_links($type, $path);
  // When node not published, links don't have href so we use path instead
  // Note: this is a bug in Core translation module, see http://drupal.org/node/1137074
  if (!empty($links->links[$langcode]) && !empty($links->links[$langcode]['href'])) {
    $options += array('attributes' => array(), 'html' => FALSE);
    $options['attributes'] += $links->links[$langcode]['attributes'];
    $options += $links->links[$langcode];
    $path = $links->links[$langcode]['href'];
  }
  
   if (empty($options))
	{
	$installed_languages = language_list();
	$language = $installed_languages[$langcode];
	$options['language'] = $language;
	}
	
  return l($text, $path, $options);
}

Do you think my proposition is right ?

As it to be proposed as a patch ?

rghazaliii’s picture

Thank you crispynewt for your great module. it really saved me. thanks a lot again.