Get All Languages
We are utilizing 15 different languages for our site. I am attempting to get all languages for some current functionality that I have which needs done for all languages. I need to get all languages then do a "foreach" on each language. Any help would be greatly appreciated!
Hi Jared,
In order to get all of the cultures of a certain object you first need to know all of the cultures you have. Please see the code below for further reference:
NewsManager manager = NewsManager.GetManager(); var items = manager.GetNewsItems(); foreach (var item in items) Thread.CurrentThread.CurrentCulture = new CultureInfo("en"); var title = item.GetValue("Title"); Thread.CurrentThread.CurrentCulture = new CultureInfo("fr"); var title = item.GetValue("Title"); I know all the languages, but I do not want to hard code the languages. Is there a way to get all the languages? I want to GetAllLanguages, then for each language "do something".
I resolved my issue and here is what I did:
CultureInfo[] languages = SystemManager.CurrentContext.AppSettings.DefinedBackendLanguages;
This got all the languages and here is what I did to see the results:
foreach (var language in languages)
resultLanguages.Text += language.ToString() + "<br>";
I was wrong above as I pasted the incorrect code.
Instead of "CultureInfo[] languages = SystemManager.CurrentContext.AppSettings.DefinedBackendLanguages;"
I meant "CultureInfo[] languages = SystemManager.CurrentContext.AppSettings.DefinedFrontendLanguages;"