Sun Java Solaris Communities My SDN Account Join SDN

Article

I18N Testing: Source Code Testing Using catgets

 
 

The purpose of these tests is to verify that the appropriate strings are processed with catgets. Not every string needs to be processed in this way, since some strings are not to be sent to the user and other strings should not be translated.

What the Tests Do and Do Not Check


Quoted strings that do not have catgets on a line are flagged. When checking for lines that should use catgets, lines that contain the word catgets are also flagged.

Certain lines of code--lines that, in most cases, should not be translated--are skipped. Other lines that should not be translated must be judged on a case-by-case basis. You can use filters or other tools to omit these lines from results files. Developers can then analyze the results files and make decisions. In any case, the scripts are customizable.

The scripts do not flag the following strings with a potential error if no catgets are present:

  • NOCATGETS or NOI18N
  • Commented lines, if the comment is all on the same line or multiple lines.
  • Only formatting strings such as "%s%4d%lxn", or strings with non-alphanumerics, or strings with just "n".
  • getopt statements
  • Simple file mode "r+" "rw"
  • #include
  • #pragma ident
  • A blank string, like " ".
  • "..", /"." ,"../" ,"./" that relate to directory paths.
The items in the following list are usually not translated. You can run a filtering program after the test script to rule them out:
  • names of devices, such as /dev/xxx
  • directory paths
  • filenames
  • exec and spawn arguments
  • certain strcmp, strcat arguments
  • certain sprintf args if building a string not to be translated
  • environment variables
  • words in resource lists if not to be translated
  • library routines, system calls, UNIX, and shell commands
  • routines that pass strings that are not to be translated
  • any messages not sent to the user
  • strings that have only special characters such as : or - that are not translated
  • many #defined strings

Samples and Scripts


NOTE: Please remember that these are sample scripts and tools that may need customization for the syntax, naming conventions, and locations of your product's message files. Many of the scripts are working versions that change dynamically to reflect changes in developing products; they may contain comments and alternate lines.

  • This is the actual test (perl script).
  • This is an example of a script that calls the test. Modify it for your environment, including all necessary source code locations and file suffixes.
  • This is a sample of a results file after the test has been run. Note that each line indicates a potential error. As mentioned above, it may not be an actual error. A line with no errors noted means that no potential errors were found in that file.
  • Here is a sample filter that can be used to post-process the results. Modify it for your environment to include strings that are not wrapped with catgets and not meant to be translated.

Back to Top

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.