How to get fallback language from LANGUAGE setting...
# help-with-umbraco
r
Umbraco 13.5.3 Multi-culture site. "nb", "en" and "en-ca". "nb" is default-Language. "en" is the fallback language for "en-ca". I have to get the "en" translations when "en-ca" translation is not created. Umbraco.GetDictionaryValue("send") I could get fallback culture translations from below code. var currentCulture = _variationContextAccessor.VariationContext?.Culture ?? "nb"; var fallbackLanguage = _localizationService.GetLanguageByIsoCode(currentCulture)?.FallbackIsoCode ?? "nb"; Umbraco.GetDictionaryValue("send", new CultureInfo(fallbackLanguage)) Question is that is there any method exists in Umbraco to get FALLBACK culture translation when current culture translation is empty.
k
Doesn't
_localizationService.GetLanguageByIsoCode(currentCulture)?.FallbackIsoCode
get you the fallback language code?
r
Yes, as I mentioned, I applied the same to get the fallback language code and then pass the CUTLTURE to GETDICTIONARYVALUE. Question is there any method in Umbraco to get fallback translation value by default when current culture translation is empty for ex. Fallback.ToLanguage that is use to get fallback culture property value.
k
For the entire rendering pipeline, if you set the Variation Context https://docs.umbraco.com/umbraco-cms/reference/language-variation Umbraco will change where it gets content from. This can make "entire pages" use a fallback language. For normal properties, you can render values "with fallback" https://docs.umbraco.com/umbraco-cms/reference/querying/ipublishedcontent/properties#fallback-to-language. This can make specific properties use a fallback language. But for getting specific dictionary enties I don't think there's a built-in fallback. As a last resort, wrap your code above in a helper method and use that instead of e.g.,
GetDictionaryValue("send")
.
r
Thanks
k
If you find a good solution (ootb or not) for fallback dictionary entries, please paste it here for future reference. 🙂
r
👍
14 Views