Internationalization and localization tools


Scanning Source Code

This section describes how to scan source code with the Globalyzer Client and how to use the Scan Results table to filter and sort the potential internationalization issues detected by the scanner. This section discusses the following topics:

Create a Project and Scans

Before you scan code, the Globalyzer Client must be configured appropriately. Here is a checklist of tasks you need to do to prepare to scan code:

  • Configure the Rule Sets for your project using the Globalyzer Server. Click here for information on managing Rule Sets.
  • Create a Project to hold your configuration settings. Click here for detailed information on how to create a new Project. If you already have created a Project, click here for instructions on opening an existing Project. Once Globalyzer is using the desired Project, you'll want to check and modify the settings in the Scanning screen in the Project Properties dialog box. Click here for detailed information on configuring the project and its scans.

Starting a Scan

To scan the code in your source path, do one of the following:

Click the Scan button in the Toolbar.

From the Menubar, select Scan=>Scan Code

Press F9.

As the Globalyzer Client scans your code, status messages are printed in the Status pane, at the bottom of the main window.

When the scan finishes, the detected problems are displayed in the Scan Results table in the upper-right side of the Main window.

Stopping a Scan

The Scan dialog box displays while Globalyzer is scanning your source code. To abort the scanning process, click the Stop Scan button.

The Scan Results table will contain the potential i18n issues found before the scan was interrupted.

Scan Results and Reports

A Globalyzer code scan can produce three different types of output.
  • Scan Results, which are stored in the database set up during installation. Within Globalyzer, the Scan Results table is a sortable, selectable table and is used to view and fix specific issues detected in the code.
  • Quick Summary. This reports the number of each type of issue detected in the source code. In the case of Unsafe Methods, hyperlinks are provided to give you help in determining how best to replace or refactor the references.
  • Generated Reports. The Generate Report feature allows you to export the Scan Results to a number of different types and formats, such as Detailed CSV Reports, Aggregate and Detailed Excel Reports, HTML Summary Reports, and Summary Reports as Plain Text files.

When you complete a scan, the Scan Results table generated by the scan is automatically displayed in the Scan Results pane. An report is also automatically opened in the Quick Summary pane.

Scan Results

Scan results are displayed in the Scan Results pane.

The Scan Results table itemizes each potential internationalization problem that was detected and reports the following information:

  • the type of issue (to switch between types, use the Results dropdown)
  • the status of the issue (to display different statuses, click the Status button)
  • the source file in which the issue was found
  • the line number of the issue
  • the actual issue
  • the code line in which the issue was found
  • the reason for the detected or filtered issues

The Scan Results data is stored in the database you chose during the Globalyzer installation process. If you chose the default, it will be in your home directory (/Documents and Settings/[Login Name] on Windows). The default directory for the database files is called .globalyzer.

The Scan Results table is used to filter, edit and fix issues. For detailed information on using the Scan Results table, see the following section Editing Scan Results.

Quick Summary

In addition to the Scan Results table, a summary of the currently-selected results is displayed in the Quick Summary pane (bottom left corner). This includes information about lines of code scanned, issues found, and in the case of Unsafe Methods, links to information that can be used to understand and address their i18n issues.

The following figure shows a portion of the Quick Summary. Note that the Unsafe Methods that were detected are listed and that they are hypertext links. Click these links to learn more about the unsafe methods and techniques for re-coding or replacing them.

Generating Reports

To generate a report of your scan results:

Select Tools=>Generate Report from the Menubar.

Click the Generate Report button in the Toolbar.

Click here for more information.

Source Files

Opening Source Files

To open a source file in the Source Files pane, do one of the following:

In the Scan Results table, double-click on a row to open the source file associated with the issue.

In the Scan Results table, single click on a row to select it, and then right-click and select Open Source File from the menu. Alternatively, you can select File=>Open Source File from the Menubar.

Use the File=>Open function on the Menubar to open a source file that is not currently associated with a row in the Scan Results table.

Right-click on the file tab of an already open source file, and select the Open menu item.

In the Source Tree pane, navigate to the file you wish to open and double-click it, or right-click on it and select Open.

Saving and Closing Files

The procedure for saving and closing files is similar to opening them. Most of the menus described in the previous Opening Files sections also contain functions for Save, Save All, Close, and Close All. For information on these functions, click here.

Editing Scan Results

In addition to displaying all the issues found during a scan, the Scan Results table supports various editing features that can help you to categorize and narrow down the scope of the code-fixing effort.

The Results Table provides these basic editing functions:

  • Sorting
  • Searching
  • Changing a row's status
  • Applying filters to the table

Sorting Scan Results

You can sort the Scan Results table by any column. Just click in the header of a column to sort the data in ascending order. Click again to sort data in descending order.

Set Status tip: Use the status settings to differentiate between different kinds of issues. For example, it might make sense to mark all string concatenations ToDo and then temporarily hide them (by unchecking the Status ToDo) while you deal with the regular strings.

Searching Scan Results

To search for text in the current page of the Scan Results table, do one of the following:

Right-click anywhere in the Scan Results table and select Search=>Find in Results from the menu.

Press Ctrl-F.

Select Search=>Find in Results from the Menubar.

The Find in Scan Results dialog box displays. For detailed information on this dialog, click here.

Scan Result Filters

Click the Filter button to create filters for your Scan Results. Filters are useful when you have many results that you want to address in more manageable chunks. For example, in C++, you could create Filter for your Embedded String scan that just displays AfxMessageBox calls. The filter is applied to all results, not just the current page's results. Once you've created and saved a filter, select it from the Filters dropdown. Click here for information on the Filters Dialog box.

Changing Status of Scan Results

After scanning code, users typically wish to refine the results of the scan by removing rows from the Active Scan Results that do not contain valid issues. For instance, you may notice that the scan detected embedded strings that do not represent display text (end-users will never see them). In this case, you have two choices:

  • refine the Rule Set and re-run the scan, or
  • change the row's Status in the Scan Results table to something other than Active

In either case, your goal is to produce Scan Results that accurately reflect the internationalization issues that need to be fixed. For instance, a refined or edited Scan Results table allows you or another user to move efficiently through the problems and fix them.

You can change the status of a single row, multiple contiguous rows, or multiple non-contiguous rows.

To select a single row, click in it. To select multiple contiguous rows, click on the first row then press the left mouse button and drag (or shift-click on the last row). To select multiple non-contiguous rows, click each row while holding down the Ctrl key.

To change the status of the selected row(s) do one of the following:

Right-click and pick Change Status from the dropdown menu and choose a different status.

Press one of the Ctrl-Alt keys listed below.

  • Active: Ctrl-Alt-A
  • Invalid: Ctrl-Alt-X
  • Ignore: Ctrl-Alt-I
  • Resolved: Ctrl-Alt-R
  • ToDo: Ctrl-Alt-T
  • Filtered: Ctrl-Alt-F

To view Results with a Status other than Active or ToDo (the default), click on the Status button and check the statuses you want to display in the Scan Results table.

Refining Rule Sets

As mentioned previously, after scanning your code, you might wish to return to your Rule Set and edit it to refine the results of a subsequent scan. It is possible that you will do this iteration more than once.

Say, for example, your code contains numerous calls to a proprietary method called getSystemInfo. This method takes a string argument that is simply the key to retrieve some information needed by your application. This string is never displayed in your application's GUI, but it keeps showing up in the Globalyzer Results Table as an issue.

You could go through the Scan Results and delete each row containing said key, but this won't help you the next time you scan the code. The best way to solve the problem is to go into the Rule Set you used to scan the code and add a new String Method Filter: getUserInfo. When you rescan the code, Globalyzer will make sure that each string it detects is not an argument to getUserInfo before it is added to the Active Scan Results.

1. Log On to the Server
Rule Sets must be edited on the Globalyzer Server, using a browser. The first step is to log in to your account on the server.

2. From your home page, click View My Rule Sets.

3. In the All My Rule Sets page, click the Edit button next to the Rule Set you wish to edit.

4. Click on the Detection, Filter or Retention rule you wish to edit. Remember that Detection Rules specify patterns the scanner will find and report, Filter Rules specify patterns the scanner will ignore, and Retention Rules allow you to override Filter Rules. The choices are:

  • Source File Extensions
  • Locale Sensitive Methods
  • Static File References
  • General Patterns
  • String Literal Filters
  • String Method Filters
  • String Line Filters
  • Method Line Filters
  • Static File Filters
  • Static File Line Filters
  • General Pattern Line Filters
  • String Retention Patterns

For detailed information on modifying each of these types of rules, click here.

Inserting Ignore Comments

Use Globalyzer's Ignore Comments feature to insert the following types of comments into your source code:

  • To Do comment -- This comment is simply a string that you or others can later search for in your source code. It may be used for any purpose that you wish.
  • Ignore Next Line comment -- This comment is a string that Globalyzer looks for while scanning your code. When the scanner finds an issue of any type in the source code, before reporting it as an issue it first checks to see if the previous line contains an "Ignore Next Line" comment. If it does, the issue is ignored.
  • Start Ignore comment -- This comment is a string that Globalyzer looks for while scanning your code. When the scanner finds a "Start Ignore" comment, it looks for the "End Ignore" comment, and ignores all the lines between the two comment strings.
  • End Ignore comment -- This comment is a string that Globalyzer looks for while scanning your code. When the scanner finds a Start Ignore comment, it looks for the End Ignore comment, and ignores all the lines between the two comment strings.

To insert a comment into a source file, either double-click on the Scan Results Issue or set the cursor in the source file at the position where you want the comment to appear, and do one of the following:

Select the Paste Comment button on the Toolbar. This brings up the Insert Comment dialog box, where you choose which type of comment to insert. For information on this dialog, click here.

Select Fix Code=> To Do Comment (or one of the other comments) from the Menubar.

In the Source Files pane, right-click and select one of the comment functions from the Fix Code menu.

The comment will be inserted above the current source code line.

You can change the default text associated with these comments in the Project Properties dialog box. Click the Project Properties button or select Edit=>Project Properties from the Menubar. In the dialog, click Scanning under your scan's name. For detailed information on Globalyzer Ignore and ToDo comments, click here.

 

 User's Guide Contents

 

Lingoport internationalization and localization services and software