Toolbar icons disappear with translated menu

The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

D8MI

(Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

Comments

Ha! Haha! Do we have anything in $item that would get us the pre-localisation title? That might be a good stop-gap unless we want to move it to depend on paths instead, which are more stable (but also need to make sure not aliased or prefixed when checked).

So based on the docs on _menu_link_translate(), link_title would indeed be the non-localized title:

* @return
* Returns the map of path arguments with objects loaded as defined in the
* $item['load_functions'].
* $item['access'] becomes TRUE if the item is accessible, FALSE otherwise.
* $item['href'] is generated from link_path, possibly by to_arg functions.
* $item['title'] is generated from link_title, and may be localized.
* $item['options'] is unserialized; it is also changed within the call here
* to $item['localized_options'] by _menu_item_localize().

Not sure how title callbacks are involved, but looking at this code it seems to be right.

A much simpler and more flexible way to this is to add a 'menu-data' attribute to every menu link and use icon fonts. I submitted a feature request at #1836160: Support icon fonts in menu links but so far no input. I will propose a patch in the next day or so. It is Language independent and not dependant on any static code elements. It would also provide the ability for anyone to design their own icon set to serve regionalization and creativity.

I think class that should be tested for is icon-content. in #10 with the fix it has the class icon and icon-content, the second screenshot, there is the class icon and icon-content-af but no actual icon.

This might have extra things, but I think tests that the class on the icon is not the title (menu title?)

Setting the default language did not seem to make the url inside the tests go to /xx/. I checked the verbose message screenshots, the url had /en/... explicitly.

So I told it to go to /xx/whatever and looked for the class there.

I'm hoping that the tests only comes back failing on core. with just one fail (the class).
there are other asserts in there, that just make sure that the menu item was in fact translated. those might be taken out.

similarly here. we should mention the point is to test if the images show on translated items, we do that by checking the class. (or something about the icon images) And it should end in a period as it should be a sentence.

Oh, I forgot to mention, one of the main things is the change from class= to class contains. Since the class is not just "icon-structure" but, for example: "icon icon-structure", because there can be more than one class on something.

A more natural way to get this into the database would be to visit a page which shows the toolbar in the foreign language. If you want to keep t(), the langcode is not relevant for it to be added to sources. Also the cache clear does not seem to be needed since you only check the site via HTTP later too.

+++ b/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarMenuTranslationTest.phpundefined
@@ -0,0 +1,100 @@
+ // Make sure will be able to translate the menu item.

-> Make sure the menu item is translated.

+++ b/core/modules/toolbar/lib/Drupal/toolbar/Tests/ToolbarMenuTranslationTest.phpundefined
@@ -0,0 +1,100 @@
+ // The icons are included based on the menu item class link title. Test that
+ // class remains the same after translation.

-> Toolbar icons are included based on the presence of a specific class on the menu item. Ensure that class also exists for a translated menu item.

Make sure will be able to translate the menu item. is actually making sure that the string Structure is found untranslated. Because I was having trouble while getting the test to work, that it was not available for translation. Now that the drupalGet is in there, and it is finding it. I think the test to check it *was* translated is enough and this test can come out:

I hope I'm not mistaken but I've just experienced this issue in alpha-5 release so it must have been introduced back somehow.
I've changed "Content" in Administration menu and the icon is gone. I've put it back to Content and it works again. Seems exact the same issue.