Globalizing a toolkit

You can load and format string resources for different locales using the tools that are provided.

About this task

You can add translatable text elements into cgt code generators so that the toolkit can generate locale-sensitive, compile-time messages. You can also instrument the toolkit operator code to access locale-sensitive strings at run time for use in the data processing or for writing to the system log file.

Procedure

  1. Create the toolkit directory.
  2. Create the toolkit information model file, info.xml, and define any resources to be generated.
  3. Create the underlying operators and SPL code.
  4. Create the resource files.
  5. Run spl-make-toolkit to generate or regenerate the C++ header and Perl module, and include these files in your C++ or Perl (cgt) files.
  6. Use the macros that are defined in the C++ header or the subroutines that are defined in the Perl module to access the translated and formatted strings.
  7. Use the formatted string in the operator code. The string type is a std::string in C++ and a UTF-8 string in Perl.
  8. Run spl-make-toolkit to generate and validate the code generators.

Example

Teracloud® Streams provides the Localization sample application to demonstrate the use of a resource bundle to hold translatable messages that can be loaded at compile time or at run time. The translatable messages are formatted appropriately for the execution locale. The Localization sample is installed in the $STREAMS_INSTALL/samples/spl/features/Localization directory.