Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Fallback.ToDefaultLanguage to get fallback value from the default language #8349

Closed
ronaldbarendse opened this issue Jun 29, 2020 · 1 comment

Comments

@ronaldbarendse
Copy link
Contributor

As discussed in modelsbuilder/ModelsBuilder.Original#206 and modelsbuilder/ModelsBuilder.Original#235, the current options to get fallback values are quite minimal or very verbose. Some things can be fixed within Models Builder (e.g. generating additional extension methods accepting fallback options), customizing the model classes or even replacing the IPublishedValueFallback.

One thing that might be a good addition is adding Fallback.ToDefaultLanguage, so you can get a fallback value from the default language without configuring the fallback chain on the languages themselfs.

The default PublishedValueFallback implementation already depends on ILocalizationService, so getting the default langauge can be done using _localizationService.GetDefaultLanguageIsoCode():

public PublishedValueFallback(ServiceContext serviceContext, IVariationContextAccessor variationContextAccessor)
{
_localizationService = serviceContext.LocalizationService;
_variationContextAccessor = variationContextAccessor;
}

Looking at the code and comments in this class, it already requires some attention. Most of the logic can be moved into a base class, so replacing it with a custom implementation (e.g. using a custom language fallback chain or recurse ancestors & languages) can be written a lot easier!

@umbrabot
Copy link

Closing this in relation to #8350 - make sure to read the close reason on #8350

@umbrabot umbrabot removed the state/needs-investigation This requires input from HQ or community to proceed label Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants