Handling translation

Created on 28 July 2022, almost 2 years ago
Updated 24 October 2023, 8 months 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.69.0 2024