I'm trying to implement some language-related customizations, for which I need to get one of the following from C# inside a ContentFinder:
Preferred: a list of the languages/cultures configured for the site in Settings
Fallback: a list of all the languages/cultures available in Umbraco
I know I can get the allowed cultures from a root content node, but I want to avoid the overhead of querying a specific node, as the code is going to be called on every page request.
If anyone could point me in the right direction, it would be a big help.
I probably will need to cache this result. Can you tell me what method you would suggest to perform the caching? This is inside an Umbraco ContentFinder.
Get all configured cultures in C#? (Umbraco 8)
I'm trying to implement some language-related customizations, for which I need to get one of the following from C# inside a ContentFinder:
Preferred: a list of the languages/cultures configured for the site in Settings
Fallback: a list of all the languages/cultures available in Umbraco
I know I can get the allowed cultures from a root content node, but I want to avoid the overhead of querying a specific node, as the code is going to be called on every page request.
If anyone could point me in the right direction, it would be a big help.
Thanks.
Hi David,
The Localization service will return all installed languages
It is a back office service so you might want to cache the results if you hitting it a lot.
Kevin,
Perfect, this is exactly what I needed!
I probably will need to cache this result. Can you tell me what method you would suggest to perform the caching? This is inside an Umbraco ContentFinder.
Hi
I would lean towards using the
AppCache.RuntimeCache
(good small example here https://our.umbraco.com/Documentation/Reference/Cache/examples/tags#tagservice)
And probibly something that clears it on the
LocalizationService.DeletedLanguage
orLocalizationService.SavedLanguage
event just to be safe.Perfect, thanks again!
is working on a reply...