Localization service : multiple fallback languages


Hi Everyone, 

I'm currently looking into providing multiple fallback languages (based on the fallback languages configured per page in EPiServer CMS) when retrieving translate labels from the localization service. 

The idea was to get the fallbacks for the current page, and effectively "test" to see if a label was available in a given fallback language - if it isn't, try the next one, and so on. 

The problem I have is that when making a call such as this one:

var labelInLanguage = LocalizationProvider.Current.GetStringByCulture(label, language);

Inside GetStringByCulture in the localization service I see:

CultureInfo actualFallbackCulture = this.GetActualFallbackCulture(fallbackBehavior, culture);
string localizedString;
if (this.TryGetStringByCulture(resourceKey, normalizedKey, culture, actualFallbackCulture, out localizedString))
return localizedString;
return this.GetMissingFallbackResourceValue(fallbackBehavior, fallback, resourceKey, culture);

GetActualFallbackCulture will give me the invariant culture for my culture I've provided - in trying to get a string for en-US it will provide me with an EN culture and use this in the TrygetStringByCulture call just below it.
So it seems like I will always get a value back from the localization service regardless of if I specify no fallbacks in the provider.

The above logic looks inevitable no matter what localization configuration I use, which means I'd have no way to know if the fallback language I've provided has an actual localized label, or if its the result of the invariant culture being used.

Any help or insight is much appreciated!



Edited, May 13, 2019 14:54

In the end I just implemented my own ProviderBasedLocalizationService, and overrided the GetStringByCulture method to do what I wanted - namely, to remove the logic to get the actual fallback culture from the invariant culture of the requested language. 

May 21, 2019 17:18
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.