Localized strings

Localized strings can be used to implement internationalization in your application or to use site-specific text (for example, when business terms change based on territory).

The Localized Strings feature allows:

  • the captions (titles of report objects) to be customized.
  • The translation of the Text property to be customized.

You could have multiple external string files, each containing the translated string in a different language. The DVM (runtime system)runtime system searches the files in order to assign text in the report definition. The localized text replaces the captions and other specified text at runtime, choosing the correct string file based on entries in the file fglprofile.

The Source String file

A text file, with a str extension, defines the string to be displayed for the report object captions or the specified Word Box or WordWrap Box text. You can check the Text property of the report object to determine the exact string to be replaced.

Syntax:
"identifier" = "string"

where:

  • identifier is the value of the Text property of the caption or label that you want to localize
  • string is the text that you want to be displayed instead

The backslash "\" is accepted as the escape character, to define non-printable characters.

Example file captions_en.str:
"Userid" = "Client ID"
"Shipcity" = "City"

At runtime, the text 'Userid" or "Shipcity" displays in the report as "Client ID" and "City".

This source string file should be added to the Genero Studio Project Manager application node for your report program, so it can be compiled when the application is built. The compiled file (42s) is not linked into the Genero executable.

Note: Although you can call the API function fgl_report_setCallbackLocalization() in your 4GL source code to specify that the caption of the report object be used, we recommend using localized strings.

Using the translate function

Entries in the source string file can also be used by the translate PXML function to replace text in an expression that sets a property value. For example, if you set the text of a Word Box to this value:
"hello "+"world".translate() 
and you have this entry in the str file:
"world" = "universe"

then the final text displayed on your Word Box is “hello universe”.

Entries in fglprofile

You can specify the compiled string file, or a list of these files, with entries in an fglprofile configuration file. For example:
fglrun.localization.warnKeyNotFound= false     -- don't display warnings on errors
fglrun.localization.file.count = 1             -- number of string files 
fglrun.localization.file.1.name = "captions_en.42s" -- name of the string file

Use the FGLPROFILE environment variable to specify the path to your fglprofile configuration file.

See the FGLPROFILE topics in the Genero Business Development Language User Guide for complete information about the fglprofile file. See the Localized Strings topics in the Genero Business Development Language User Guide for complete information and examples.