Handling strings in a JScript Metro App


  • Is 'resources.rejson' the only way to store strings in a JScript Metro app? How would one load dynamic strings containing tokens (that are replaced at run-time based on state)? 
    Thursday, September 22, 2011 7:13 PM


All replies

  • You can store strings as variables in your .js files as well.  You can use standard jscript string functions you are used to in order to build strings dynamically.  For example you could have the string:

    // declared globally perhaps

    var myTemplate = "Hello <<namehere>> !";

    then call in your function:

    var newString =  myTemplate.replace("<<namehere>>", "skarkhanis");


    seach Bing for jscript string functions for more examples.

     also you can use localization like in this sample: http://code.msdn.microsoft.com/windowsapps/Application-resources-and-cd0c6eaa



    Jeff Sanders (MSFT)
    Thursday, September 22, 2011 7:52 PM
  • Can I put "Hello <<namehere>>" inside res.rejson? Is it possible to get access to the resource JSON object, replace all tokens and then call processall() function? From a localization perspective it is efficient to keep all the strings (including the ones with tokens) in one location (e.g. res.rejson). But then we'll also need the ability to replace tokens at run time.
    Thursday, September 22, 2011 10:01 PM
  • The sample mentioned above has useful information on run time use of strings which answers my questions for now. Thanks Jeff.
    Friday, September 23, 2011 5:39 AM