I am working on an application in mvc4.I want the application to work in English and Russian.I got titles in russian, but error messages are still in english.
My model contains:-
[Required(ErrorMessageResourceType = typeof(ValidationStrings),
ErrorMessageResourceName = "CountryNameReq")]
public string CountryName { get; set; }
if(ModelState.IsValid) becomes false it will go to GetErrorMessage()
public string GetErrorMessage()
{
CultureInfo ci = new CultureInfo(Session["uiCulture"].ToString());
System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ci.Name);
string errorMsg = string.Empty;
int cnt = 1;
var errorList = (from item in ModelState
where item.Value.Errors.Any()
select item.Value.Errors[0].ErrorMessage).ToList();
foreach (var item in errorList)
{
errorMsg += cnt.ToString() + ". " + item + "</br>";
cnt++;
}
return errorMsg;
}
But i always get error message in English.How can i customize the code to get current culture.