Handling translation

Created on 28 July 2022, over 2 years ago
Updated 24 October 2023, about 1 year ago

Problem/Motivation

I was having some issue with different translated nodes.
When Just in one language different to the main source of the site no breadcrumbs were coming though, but if the node matched the main source it was fine. It also seemed to work if you added multiple languages.

Proposed resolution

Make some changes to the way urls are generated and enabled translation for the field.

🐛 Bug report
Status

Needs review

Version

1.1

Component

Code

Created by

🇬🇧United Kingdom 3li U.K. 🇬🇧

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom justanothermark

    We were also having this problem in the latest version (1.1.1) on D10. In addition, we were also seeing computed breadcrumbs coming through using the internal path instead of the alias so for a page at https://example.com/en/foo/bar we were getting breadcrumbs of:

    * "Home": `https://example.com/en`
    * "": `https://example.com/en/node`

    instead of:

    * "Home": `https://example.com/en`
    * "Foo": `https://example.com/en/foo`

    The attached patch uses the base field definition changes from #3 but switches to use `$url->toString()` instead of `$url->getInternalPath()`. This fixes the breadcrumb computing to give the correct links & titles and also works for translations. Additionally, this should work for sites that use translations based on domains or query strings or something other than `/[langcode]/` as the first part of the path.

Production build 0.71.5 2024