locked
Javascript message localization RRS feed

  • Question

  • User1647250948 posted

    Hi

    I am using javascript to do some validation. I need to convert javascript message to local language...currently I am using resource file for other message which comes from C# language and asp .net label.  Is there any idea pls share with me.


    Thanks

    mrd

    Thursday, April 29, 2010 6:34 AM

Answers

  • User-1171043462 posted

    You can use GetGlobalResourceObject method 

    <script type = "text/javascript">
            function ShowGreetings() {
                var message = '<%=GetGlobalResourceObject("Resource", "Greetings") %>';
                alert(message);
            }
        </script>


     

    Resource is the name of Resource file and Greetings is Resource key

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 29, 2010 1:11 PM

All replies

  • User-1360095595 posted

    Maybe you can read the strings in C# and use RegisterClientScriptBlock() to register javascript variables with the localized versions of the messages.

    Thursday, April 29, 2010 6:48 AM
  • User-624088818 posted

    ResourceManager rManager = ResourceManager.CreateFileBasedResourceManager("resource", ResourceFile, null);
    string sTitle = rManager.GetString("Title");
    Response.Write("<script>");
    Response.Write("javascript:alert('"+sTitle+"')");
    Response.Write("</script>");



    Thursday, April 29, 2010 6:53 AM
  • User1647250948 posted

    I am not getting u...pls describe details.

    thanks


    Thursday, April 29, 2010 7:04 AM
  • User-1171043462 posted

    You can use GetGlobalResourceObject method 

    <script type = "text/javascript">
            function ShowGreetings() {
                var message = '<%=GetGlobalResourceObject("Resource", "Greetings") %>';
                alert(message);
            }
        </script>


     

    Resource is the name of Resource file and Greetings is Resource key

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, April 29, 2010 1:11 PM
  • User1647250948 posted

    Thanks mudassarkhan........I get my result according to your code.

    Monday, May 10, 2010 10:44 PM