- Issue created by @Yury N
- 🇦🇺Australia almunnings Melbourne, 🇦🇺
Ahh I thought I was helping when I made that change. Obviously not!
I observed that the menu() query was inheriting the route() queries language in the same request without any real instruction, possibly off the static cache context. Which looked a little buggy to me. So I locked it down.
Seems safest to make the language arg explicit on the menu() query to load the correct language on the menu link, then set the route language off the resulting url’s option.
Does that sound right? Basically do what you say 😅
Really appreciate the help with the multi lingual stuff!
-
almunnings →
committed 93eb7331 on 2.0.x
Issue #3390590: MenuItem route should not inherit language from menu
-
almunnings →
committed 93eb7331 on 2.0.x
- Status changed to Needs review
about 1 year ago 12:01am 2 October 2023 - 🇦🇺Australia almunnings Melbourne, 🇦🇺
Coolio, thats on dev
- Had to fork `route_entity` data producer completely to ensure it checked entity->hasTranslation.
- Introduced a `url_translated` data producer to set the language on a URL entity.
- Added a langcode arg to the `menu` query.From what I can tell this works pretty much as requested.
Have a play, let me know
Thanks - 🇧🇾Belarus Yury N
It seems to work for route. Thank you.
But menu item itself (title for example) is untranslated. - 🇦🇺Australia almunnings Melbourne, 🇦🇺
Hmmmm
I cant quite figure out how to get the translated menu items to load in then. Google is pretty full of misdirection around it.I can translate the URL, but I'm still digging around on how to get the actual translated menu link.
The closest to a related issue i can find is https://www.drupal.org/project/drupal/issues/2466553 🐛 Untranslated menu items are displayed in menus Needs work
Perhaps a better approach is to go all the way up to where the menu loads and add a MenuTreeParameters on the MenuTreeStorage to filter by language. Not really sure. Bit of messing around to get it to work.
I'll keep having a play in the background
- Status changed to Needs work
about 1 year ago 11:31pm 2 October 2023 -
almunnings →
committed d5e00560 on 2.0.x
Issue #3390590 by almunnings: MenuItem route should not inherit language...
-
almunnings →
committed d5e00560 on 2.0.x
- 🇦🇺Australia almunnings Melbourne, 🇦🇺
Translations are the gift that keep on giving.
Lets try these changes tomenu, query, nodeTypes
.At the top of those queries is the DataProducer
language_context
which changes the language at the negotiation level, whic will trickle down.Changing langcode in one query will change the entire language negotiation for the remainder of the query. The side effect is you cannot mix and match language queries.
Reason is to to Deferred promise nature of GraphQL, changing a language mid query does... weird things when entities load in different orders.
But perhaps this is enough so long as its documented.
Have a go at dev again please :)
- Status changed to Needs review
about 1 year ago 9:26am 3 October 2023 - Status changed to RTBC
about 1 year ago 11:17am 3 October 2023 - 🇧🇾Belarus Yury N
I was also thinking about using language negotiation in some way. Found that
GraphQL
module has it's own negotiation plugin. But did not understood where this "context" comes from.Your solution covers our use cases. Thank you.
Moving to RTBC. - Status changed to Fixed
about 1 year ago 9:57pm 6 November 2023 - 🇧🇪Belgium cedricl
The translations are coming through for items, but the field 'name' isn't being translated. I added the translation for the title of the menu here.
/en/admin/structure/menu/manage/MENU_ID/translate/fr/edit. But when querying the menu in french it still gives the label in the original menu language (Dutch) but the items are in french as should be.Extra visual info: https://imgur.com/a/RCY8rGp
Ticket should be re-opened.
- Assigned to almunnings
- Status changed to Needs work
about 1 year ago 10:19pm 20 November 2023 - 🇦🇺Australia almunnings Melbourne, 🇦🇺
Thanks for finding that.
Ok cool, lets re-opened and get that menu label translated. - Merge request !54Issue #3390590 by almunnings, Yury N, CedricL: MenuItem route should not inherit language from menu → (Merged) created by almunnings
- 🇦🇺Australia almunnings Melbourne, 🇦🇺
Sorry for the delay!
Adding `setConfigOverrideLanguage` into the pot seems to help this along.Have a play, let me know how you go.
- Status changed to Needs review
12 months ago 9:24pm 15 December 2023 -
almunnings →
committed f2c5683d on 2.1.x
Issue #3390590 by almunnings, Yury N, CedricL: MenuItem route should not...
-
almunnings →
committed f2c5683d on 2.1.x
- Status changed to Fixed
11 months ago 10:08am 4 January 2024 Automatically closed - issue fixed for 2 weeks with no activity.