umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.5k stars 2.69k forks source link

language fallback not working correctly #8615

Closed shearer3000 closed 2 years ago

shearer3000 commented 4 years ago

Sorry to reopen this ticket but it appears Language fallback doesn’t work, so I wanted to re-explain the scenario with example screenshots.

Given the CMS has two languages (English and French) - NB English is the default, and French falls back to English: language-setup

The homepage doctype has a property (multinode tree picker) for picking pods to show: english-content

Which display correctly on the website: english-website

In contrast, the French page has no content picked for this property: french-content

Given that the template integration is telling the extension method to use language fallback: var pods = Model.Value<IEnumerable<IPublishedContent>>("pods", fallback: Fallback.ToLanguage);

It is therefore expected that the content nodes (IPublishedContents) would be returned from the English language, but instead IPublishedContents with no name or url property value are being returned: debug

So the french website doesn't show anything french-website

This example is using Umbraco 8.6.3

nul800sebastiaan commented 4 years ago

That does seem rather curious, I'll need to investigate what is going on here! I'll talk to the team and get back to you.

shearer3000 commented 4 years ago

thanks sebastiaan :) BTW with 8.6.4 which has just come out, i wasn't expecting it to be fixed as there didn't look like there was a related ticket, but just confirming its still an issue after upgrading to that.

nul800sebastiaan commented 4 years ago

Thanks for the feedback, I heard back from the team and the conclusion is that: yes, this should just return the French names of the nodes as a fallback.

This has not worked properly in all of v8, sounds like it was never implemented like that. Therefore, we'd love some help getting this fixed, if you or someone else coming across this one would like to lend a hand then that would be most excellent! 👍

umbrabot commented 4 years ago

Hi @shearer3000,

We're writing to let you know that we would love some help with this issue. We feel that this issue is ideal to flag for a community member to work on it. Once flagged here, folk looking for issues to work on will know to look at yours. Of course, please feel free work on this yourself ;-). If there are any changes to this status, we'll be sure to let you know.

For more information about issues and states, have a look at this blog post

Thanks muchly, from your friendly Umbraco GitHub bot :-)

nul800sebastiaan commented 4 years ago

I believe this links closely to https://github.com/umbraco/Umbraco-CMS/issues/7692 - which is a modelsbuilder fix, maybe it's even the same problem?

shearer3000 commented 4 years ago

hi Sebastiaan, yes sounds closely linked. Although, i have able to produce the issue on both a site using modelsbuilder and one without it, so potentially the issue is at a 'lower level' of the variants plumbing?

shearer3000 commented 4 years ago

hello - i just tried this on the 8.7RC and its still the same issue (so it doesn't look fixed by #7692 or any other variants/segments work in 8.7 as yet )

ronaldbarendse commented 4 years ago

Although it seems a little strange, this is expected behavior. Your current culture is still French (retrieved from VariationContext.Culture), even though the MNTP gets the items from the English homepage using the fallback. None of the content pickers store the selected culture (yet, see https://github.com/umbraco/Umbraco-CMS/issues/7546), so all IPublishedContent will use the current culture.

Looking at the screenshots, content node 'one' (ID 1063) is only published in English (it has only 1 culture) and therefore doesn't have a name in the current/French language. If you want the English name/URL, you need to manually specify the culture when retrieving the values, e.g. pod.Name("en").

The UmbracoContext.ContentQuery.Search(...) method uses a work-around to allow rendering the search results in another culture by wrapping the IEnumerator with some logic that switches the current culture: https://github.com/umbraco/Umbraco-CMS/blob/12e88fde423f59eae1dff76b474974382d672fe3/src/Umbraco.Web/PublishedContentQuery.cs#L272-L340

This has a nasty side-effect of changing the whole ambient current culture, so not only the search results are retrieved in the altered culture, but also all other content. I don't think we want this solution (or if it's even possible) with content retrieved in another culture (e.g. using a fallback). I also don't think we should filter the results returned from the MNTP based on whether it's published in the current culture, as you might want to render it in another culture anyway...

shearer3000 commented 4 years ago

hi Ronald - thanks for that explanation. At that point I think that makes it slightly unclearer for our content authors as to what the exact purpose/function of the "language fallback" is. Their understanding is that if there is no french content then it would simply use (fallback) to the english content instead (based on the CMS configuration in this scenario of French with a fallback of English)

Or are you meaning it would do that once the #7546 ticket is implemented?

thanks Andrew

ronaldbarendse commented 4 years ago

@shearer3000 I think you're confused about what you define as content: in this case, it's only the selected nodes (more specifically the content UDIs). If the French page doesn't have any selected nodes, it will use the language fallback and return the selected nodes from the English page.

What you're doing next it rendering content (e.g. name and URL) of the selected nodes, which will return the content in the current culture (which is French). This is not content that's related to the picked nodes, as that only stored a reference.

If #7546 is fixed, that would allow storing the selected node culture alongside the content UDI, which might indeed help fix this problem (as you can than always use that culture to render the name/URL of the selected content). In any case, it will require some additional code to make it work like you and/or your editors require.

Milo-W commented 3 years ago

Hello,

I am trying to find out whether an issue has been posted that I'd like to post. It seems close to this topic.

What I have observed (Umbraco 8.x, not some latest one so I don't know if it's debugged), sometimes (can't find the pattern) when I choose the - I call it so - "context language" (the main lang in the panel), and I am at a subpage node, I don't always get this context language's web page to operate with. E.g. I have English as the main language, I switch to e.g. French, I click a subpage, and I see an English page (the content, meta, etc.) in the main area.

Has anyone seen this? Do you remember if it was solved at some point in 8?

Thanks,

umbrabot commented 2 years ago

Hiya @shearer3000,

Just wanted to let you know that we noticed that this issue got a bit stale and might not be relevant any more.

We will close this issue for now but we're happy to open it up again if you think it's still relevant (for example: it's a feature request that's not yet implemented, or it's a bug that's not yet been fixed).

To open it this issue up again, you can write @umbrabot still relevant in a new comment as the first line. It would be super helpful for us if on the next line you could let us know why you think it's still relevant.

For example:

@umbrabot still relevant This bug can still be reproduced in version x.y.z

This will reopen the issue in the next few hours.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face: