backdrop / backdrop-issues

Issue tracker for Backdrop core.
145 stars 40 forks source link

Translated content doesn't get aliased path in views path #6746

Closed olafgrabienski closed 2 weeks ago

olafgrabienski commented 3 weeks ago

Description of the bug

This is a follow-up to #6745 (about views Title fields with links). This one here is about views Path fields:

Paths to translated content which is listed in views, e.g. on the "Manage content" page, aren't rendered as the aliased path. Path aliases in views work only, if interface and content language are the same.

Steps To Reproduce

To reproduce the behavior:

  1. Enable Content Translation, Language and Locale from Backdrop core.
  2. Add a second language, i.e. German.
  3. Configure the Page content type, go to the tab "Multilingual support", and choose "Enabled, with translation".
  4. Create a page of title "Hello world", put some content in the body, set the language to English, and save the page. The page gets a URL like example.com/hello-world.
  5. Hit the "Translate" tab, and add a translation. The translated page gets a URL like example.com/de/hallo-welt.
  6. Switch the Backdrop interface back to English, using the language switcher in the Admin bar.
  7. Go to the Manage content page, edit the view and add a Path field.
  8. Back on the Manage content page, inspect the path of the pages created above.

Actual behavior

The path of the English page "Hello World" is the alias /hello-world (as expected). The path of the translation "Hallo Welt" isn't an alias but the node ID path, e.g. /node/7.

Expected behavior

The path of the translation "Hallo Welt" is an alias, e.g. /de/hallo-welt.

argiepiano commented 3 weeks ago

PR submitted.

The PR actually sends the language object to l() in order to get the aliased path when available. Before the PR, there was no attempt to get the aliased path, despite the description of the views field!

robertgarrigos commented 3 weeks ago

Great. This PR fixes the problem for me.

Content___My_Backdrop_Site_-_Vivaldi

olafgrabienski commented 3 weeks ago

Same here, works for me as well (with slightly different language settings). Many thanks!

herbdool commented 3 weeks ago

Code looks good too.

olafgrabienski commented 3 weeks ago

Thanks, @herbdool! What do you think about the PR code for the related issue #6745?

quicksketch commented 2 weeks ago

I merged https://github.com/backdrop/backdrop/pull/4896 into 1.x and 1.29.x. Thank you @argiepiano, @olafgrabienski, @robertgarrigos, and @herbdool!