locked
languages in a web form RRS feed

  • Question

  • User1929727834 posted

    In a web form application I support, I need to have the web pages display in the following new languages:

    Karen, Burmese, Nepali, and Arabic. Right now the application is displayed in English and Spanish.

    My question is how to have the pages display in the various languages and here is what I am thinking:

    Have the html that is generated point to the various languages by using different fonts. For example: 

    For the Karen language, the font would be 'Karen Hiland',

    For Arabic language the font would be 'Arabic (Iraq),

    If the above would not work, what would the web form need to make the html display to show what language is currently being displayed?

    if that does not work, what would you suggest I do to accomplish my goal?

    Monday, June 3, 2019 2:12 AM

Answers

All replies

  • User753101303 posted

    Hi,

    Depending on this is done currently you could use https://support.microsoft.com/en-us/help/917414/how-to-use-application-resource-files-resx-to-efficiently-create-a-loc

    Also I'm using a general CSS sheet as well as language specific sheets with few changes.  For Arabic https://www.w3schools.com/tags/att_global_dir.asp does quite a nice job though you may have some little things to change here and there (for example if you have arow images or whatever).

    Selecting a font (you'll provide a list so that it can still fallback as needed) shouldn't be a real issue.

    Monday, June 3, 2019 8:09 AM
  • User-1174608757 posted

    Hi dcofmaha,

    According to your description, you could specify the language of the entire webapplication  by modifying the Globalization.CultureInfo in global.asax in web form.

    1.You should create a resx file to specify resource of language in App_GlobalResources, you could see as below:

    2.Add below code in Gloab.asax file

    void Application_BeginRequest(Object sender, EventArgs e)
            {
                // Code that runs on application startup
                HttpCookie cookie = HttpContext.Current.Request.Cookies["CultureInfo"];
                if (cookie != null && cookie.Value != null)
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(cookie.Value);
                    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cookie.Value);
                }
                else
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("en");
                    System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en");
                }
            }

    3.You could add  a dropdownlist to select language and you could set language in SelectedIndexChanged in code behind;

     protected void ddlanguage_SelectedIndexChanged(object sender, EventArgs e)
        {
            Session["language"] = ddlanguage.SelectedValue;
            //Sets the cookie that is to be used by Global.asax
            HttpCookie cookie = new HttpCookie("CultureInfo");
            cookie.Value = ddlanguage.SelectedValue;
            Response.Cookies.Add(cookie);
            //Set the culture and reload for immediate effect.
            //Future effects are handled by Global.asax
            Thread.CurrentThread.CurrentCulture = new CultureInfo(ddlanguage.SelectedValue);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ddlanguage.SelectedValue);
            if (cookie.Value == "en") { Session["ddindex"] = 0; } else if (cookie.Value == "fr") { Session["ddindex"] = 1; } else if (cookie.Value == "de") { Session["ddindex"] = 2; }
            Server.Transfer(Request.Path);
        }

    4. In the front end, you should use Text=”<%$Resources:Resources,FieldName %> to show the text of controls

    Here is the link, I hope it could help you.

    https://codepedia.info/multiple-languages-website-asp-net-c/

    Best Regards

    Wei

    Tuesday, June 4, 2019 2:20 AM
  • User-1038772411 posted

    Hi Dcofomaha

    This one is very big concept  so i am providing you one refence link so you can read and apply in your project 

    https://stackoverflow.com/questions/26113980/how-to-make-my-webform-to-be-multi-language

    Thanks

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 4, 2019 11:47 AM