locked
How to localize text in Javascript code RRS feed

  • Question

  • User206383436 posted

    I use Javascript functions in all of my web forms, such functions can be included directly into the web form of through an external .js file. Part of this Javascript code does client-side validation and it displays messages to the user in only one language because the text in the message is written direclty into the alert commands. Does anybody knows about a way to localize text used in this manner? I have seen many approaches and it seems to me that there is not a standarized one. 

    Respectfully,
    Jorge Maldonado 

    Thursday, January 5, 2012 3:22 PM

Answers

  • User197322208 posted
    Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", _
       "function AlertHello() { alert('" + YOUR LOCALIZED STRING HERE+ "'); }", True)
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 6, 2012 10:16 PM

All replies

  • User197322208 posted

    I would pass the message as an argument to the function. The message will come from the server.

    Thursday, January 5, 2012 4:16 PM
  • User206383436 posted

    I have been thinking about your solution but I do not quite understand. I will very much appreciate if you give me a more detalied explanation. I do not see how to pass an argument from the server to a Javascript function.

    Best regards,
    Jorge Maldonado 

    Friday, January 6, 2012 11:12 AM
  • User197322208 posted
    Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", _
       "function AlertHello() { alert('" + YOUR LOCALIZED STRING HERE+ "'); }", True)
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 6, 2012 10:16 PM