0

I want a public class to display a different textbox label based on the language used on a page. For example if QueryString lang is english then the Display name should be "Email" elseif the lang if French the Display name should be "Courrier Electronique" etc etc...

Unfortunately I can't (or maybe I can!!) nest an if statement in a class to determine the language. How can I accomplish that?

string Language_qs = Convert.ToString(HttpContext.Current.Request.QueryString["lang"]);

public class LoginViewModel
{
    [Required]
    [Display(Name = "Email")]
    [EmailAddress]
    public string Email { get; set; }
}
Gloria
  • 1,305
  • 5
  • 22
  • 57
  • 1
    You need to provide a bit bigger sample (i.e. small part of your ASPX/CSHTML that renders the value)... Note that usually one uses resources for localization, so consider reading about it in free time. – Alexei Levenkov Sep 26 '14 at 06:10
  • possibly duplicate [display-name-in-mvc](http://stackoverflow.com/questions/21129447/dynamically-choose-between-two-labels-for-the-display-name-in-mvc-ef) or [setting-displayname-data-annotation-dynamically](http://stackoverflow.com/questions/3228378/setting-displayname-data-annotation-dynamically-in-asp-net-mvc) – Grundy Sep 26 '14 at 06:11
  • asp mvc resources or write your own implementation of Display attribute what would return value according language like: http://stackoverflow.com/questions/2431333/displayname-attribute-from-resources – Vladimir Shmidt Sep 26 '14 at 06:31
  • I've considered using the resources for localization but I want my page to be more flexible by determining the language manually. The reason is that one user can write replies in different languages using different templates. In other words I want the user to determine which language he/she wants to use regardless any other automated behavior..... – Gloria Sep 26 '14 at 06:32
  • you can store user preferences in session and output pages with respect of it language – Vladimir Shmidt Sep 26 '14 at 06:33

0 Answers0