Language Variation allows you to have different variations of content based on a language culture. In the documentation there are other useful articles about the feature:
IPublishedContent
contains all language variations of a node, and when rendering it out it will then use the Culture you are currently on. This can then be overridden on an individual property level if you want, like this:
Here we would attempt to render the pageTitle
property in the French variant. We want to fallback to the current culture language if it can't find it in French.
The challenge arises when trying to display all values of an IPublishedContent model in a specific culture from a "current culture"-less context, like a SurfaceController
.
If you do something like this:
You will get the root node in the default culture. However you can set a new VariationContext
like this:
So we access the IVariationContextAccessor.VariationContext
and set it to a new one with our own specified culture (remember using Umbraco.Core.Models.PublishedContent;
at the top to get access to it).
The elements you get afterward will be in the culture you have specified.