Problem/Motivation

I have installed a second language after installation and set that language as default. I now see that one of the two shortcut links is translated but the other one isn't. I can't find faults in the code for now and haven't had time for debug. See screenshot as well.
I also checked, and the string is translated for this language (i checked the po file and the translate interface config page)
Reproduce:
Install drupal, add second language (dutch) and set second language as default.

Steps to reproduce

Proposed resolution

TBA

Remaining tasks

Patch, with test
Add before/after images available from the issue summary

User interface changes

TBA

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

montesq’s picture

Version: 7.0 » 7.x-dev

Same here.
When I go to the part "translate interface", the string "Find content" is not found.
I've tried with the normal profile and the minimal profile -> same issue
I've tried to replace the $t() by st() in shortcut.install -> same issue
I'm disappointed! Has someone got an idea?

droplet’s picture

Status: Active » Closed (works as designed)

Shortcuts should not translatable in this way.

You can never find the string because SHORTCUT is manually edit. someone like to add "Find Content" as their link then "FJWIFEWI" in other language.

So, the problem is why "Add Content" is translated ??

That's because "Add Content" is linking to a page and that page title is also "Add Content", so Drupal think this is really "Add Content" than custom name.

"Find Content" is linking to a page named "Content" as title.

daften’s picture

Question: So you should create different shortcut sets based on language?
Then is there a way to automatically assign a shortcut set to a language? If not, there is still something wrong with the design.

droplet’s picture

@daften,
yes. it's something wrong with design.
#549698: Prepare field label and description for DDT (translatable queries)

shortcuts works like menu (menu is also not transable), try i18n or custom modules.

Tor Arne Thune’s picture

I marked my issue #1052478: 'Find content' not translated in Content shortcut bar as a duplicate. I also have the problem of 'Find content' not being translated, but 'Add content' is translated. After droplet's explanation and link to the real issue, I understand why.

sahuni’s picture

We still cannot translate the link "Find content" in toolsbar.
I just activated l10n_update, but no change for that link (D 7.12)

drupalcms.ir’s picture

FileSize
24.42 KB

same problem here on version 7.15 too.
we tried to find this problem but nothing !

webatelier’s picture

This is a workaround and doesn't make the "find content" item in the toolbar translatable.

Go to Administration => Configuration => User Interface => Shortcuts
Click on 'List Links' for the shorcut you wish to change and
edit the name of the link to what you want, i.c. 'Find Content' to your desired name

drupalcms.ir’s picture

Why the other links are translated by default?
For example 'Add content' has translated after import .po file , but 'Find content' still not translated.

designinmotion’s picture

I found a possibility to solve this. Click on Edit shortcuts on the right. Click on Edit near the Find content link. Change in Content. Now it's translated correctly to the language you're working in.

Nicolas Bouteille’s picture

The value 'Find content' is set in the .install file.
If you don't already have too much custom shortcuts set, you can disable Shortcut module, uninstall it, then enable it back (re-install). The text should now be translated.

Nick

nicolasg’s picture

I too came across this problem, what I ended up doing was modifying the core module to pass the link titles thru the t() function; then I could use the entity translation functions to translate the text as needed.

In modules/shortcut/shortcut.module.
Line 715 the function shortcut_toolbar_pre_render($toolbar)

Added code after the first line. As follows:

function shortcut_toolbar_pre_render($toolbar) {
  $links = shortcut_renderable_links();
  
  //NG. Pass the link titles thru the translation interface.
  foreach($links as $index => $value){
  	if(isset($value['#original_link'])){
  		$links[$index]['#title'] = t($links[$index]['#title']);
  	}
  }
....

Its not the nicest approach, but it works for me.
Im sure there must be a way to do a similar fix outside the core but I dont have time right now to try it. (Tried theme_menu_tree hook but that doesnt do what I want/need)

nicolasg’s picture

Alright well after thinking some more, I figured out a non-core-hack way of doing what I posted before.
Making use of the theme_menu_link hook.

If you just want to apply the translation to the default shortcut set (like me), you can make a very specific hook in your theme template because the default shortcut set has a set menu name 'shortcut-set-1'

//NG. Pass the link titles thru the translation interface.
function THEMENAME_menu_link__shortcut_set_1($link){	
	$link['element']['#title'] = t($link['element']['#title']);
	
	return theme_menu_link($link); //now run it thru the normal processor.
}
Nicolas Bouteille’s picture

Issue summary: View changes
Status: Closed (works as designed) » Active

I just encountered the same problem again.
#12 or similar code should be committed to core.
Shortcuts must be translatable through the admin/config/regional/translate/translate screen.
Many of us don't let end-users actually create custom shortcuts. We, site builders, create shortcuts for them and we need those to be displayed in the end-user's preferred language.

MariaIoann’s picture

#12 code fixes the problem, but I would put it inside the shortcut_renderable_links method, in order to apply to the shortcuts block too.

function shortcut_renderable_links($shortcut_set = NULL) {
  if (!isset($shortcut_set)) {
    $shortcut_set = shortcut_current_displayed_set();
  }
  $links = menu_tree($shortcut_set->set_name);

  //NG. Pass the link titles thru the translation interface.
  foreach($links as $index => $value){
    if(isset($value['#original_link'])){
      $links[$index]['#title'] = t($links[$index]['#title']);
    }
  }
  
  return $links;
}
kkalashnikov’s picture

This patch work for me

gge’s picture

#16 works for me too.

daften’s picture

It's not just this patch. When you install a site with e.g. dutch as the default language, the shortcuts are always in dutch. It's a shortcoming in the shortcut system itself which doesn't support multilingual properly it seems.

GoddamnNoise’s picture

The patch in #16 works. I agree with #18 and that won't be the only problem you'll get if you install Drupal 7 with another language different from english as default language.

Senthil Kumar Kumaran’s picture

I'm facing the same issue in Drupal 8. My problem is, i'm using Drupal composer to update core and contributed modules after each deployment. Hence, applying the patch #16 will be a hack of code for me. Can someone please validate the patch and apply the fix in Drupal core?

Senthil Kumar Kumaran’s picture

Version: 7.x-dev » 8.3.9
Priority: Normal » Major
Senthil Kumar Kumaran’s picture

Any update on this issue? or any plan when will this be addressed? or Any action needed?

Version: 8.3.9 » 8.3.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Version: 8.3.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Branches prior to 8.8.x are not supported, and Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Issue tags: +Bug Smash Initiative, +Needs tests

I tested this on Drupal 10.1.x, standard install with Italian as a second language. The shortcut links were not translated or translatable from the UI. It does seem that that ability should be added. In fact one of the shortcuts is now 'Add content' which is already translated.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.