.NET Tutorial

Wrapping It Up

Now we are back in the familiar territory of simple string externalization. The only twist here is that for strings embedded in AControl.cs, we need to replace them with a call to mgr.GetString instead of just GetString as in the web pages. But before we change our Globalyzer properties, we can externalize any strings remaining within blocks of C# in simple.aspx.

  1. If necessary, select csharp_scan from the Scan dropdown and Embedded Strings from the Results dropdown. Then, click on the File heading to sort your Scan Results according to location so that you have all of the strings within simple.aspx together. The only valid remaining string in simple.aspx should be the Timestamp: string. Double click on that row and externalize it from the source using the Externalize selected String button .

  2. Remove the two rows in your table that reference strings in the file User.cs by setting them to Invalid in the same manner as before. These items reference a person's name and so do not require translation.

  3. Now we are left with only the strings in AControl.cs. Before externalizing these strings, we need to change the String Retrieval Method that is used to retrieve the strings at runtime. This can be done individually for each scan through the Manage Scans dialog. Select Scan=>Manage Scans.

  4. The Manage Scans dialog appears. In the Manage Scans dialog, click on your scan csharp_scan. Click Modify.

  5. The Globalyzer Scan dialog pops up. The option to change the Retrieval Method is present on the third page of the dialog: the Globalyzer String Externalization section. Click Next twice to reach this section. Once there, find the Retrieval Method input area. Change Retrieval Method to mgr.GetString("[key]") and click Finish.

  6. Close the Manage Scans dialog and return to the Scan Results view. Select all the remaining rows, double check that they are all issues from AControl.cs If no unexpected issues are found, click on the Batch Externalization button . Go through the steps to do a batch externalization.


    Note: While Batch Externalization is certainly faster and more efficient than Single String Externalization, you will not be able to insert Externalized String Comments into your source code. The Externalized String Comments feature is only available when you externalize strings one at a time.
  7. Finally, select Scan=>Manage Scans, and click New to create a new Scan for scanning the JavaScript source code. Name it javascript_scan. Select the JavaScript Rule Set you created earlier from the Rule Set dropdown and select all files in the Source Files tree (or leave all of them blank). Click Next.

    Uncheck all detection types except for Embedded Strings. Click Next.

    In the Resource File Type dropdown, select resx. Leave the Retrieval Method as <%=GetString("[key]")%>, change the String Key Next ID to 300. Change the Resource File Path to reference MyResources.resx so that strings will be externalized to the same resource file. All the other fields can remain their default values. Click Finish to finally create your JavaScript scan.

    Select the javascript_scan from the Scans dropdown in the Scan Results window. This should trigger a scan. One string should be detected. The string mentions that "The database is being searched" will be displayed to the user. It should therefore be externalized. Please do so. Congratulations, you are now done with all the application strings.

Be sure to save all of your work. The fixing process is complete; we now need to compile our code and run the application to see how it works when the user changes locales.