I need to change cultures at runtime according to resource files for each culture.
I need to change the attributes of the controls in my form, according to two cultu
I have not been able to get the "fallback" as described here to work. I'm using Global resource files for language and when the label is missing from the user selected culture file it does not default back to a label in default culture? I ended up creating a method to perform the fallback. I was searching for better ways to temp change the culture (when label not found) and stumbled on this post so I thought I'd and some content.
In a utility class of mine: public String getLabelResource(String sLabelID, String sLangCd) {
cLogger oLogger = new cLogger();
try
{
Object sLabel;
sLabel = HttpContext.GetGlobalResourceObject("{filename}", sLabelID);
if (sLabel.ToString() == "") //label was not found in selected lang
{
//default to US language resource label
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
sLabel = HttpContext.GetGlobalResourceObject("{filename}", sLabelID);
//switch global lang back to selected
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(sLangCd);
}
return sLabel.ToString();
}
catch (Exception ex)
{
oLogger.LogWrite("cUtils.cs", "getLabelResource", ex.Message, false);
return String.Empty;
}
}