Localized Strings
Localized Strings allow you to internationalize your application by supporting different languages without recompiling your sources.
Concept
Any string that is used in your Genero BDL program, such as messages to be displayed or the text
on a form, can be defined as a Localized String, by using the %"…"
notation.
At runtime, the Localized String is replaced with text stored in a String File.
Defining Localized Strings in sources
A Localized String begins with a percent sign (%
), followed by the name of the
string identifying the replacement text to be loaded from the compiled String File. Since the name
is a STRING
, you can use any characters in the name, including blanks.
LET s1 = %"Greetings"
Here the string "Greetings" is both the name of the string and the default text which would be used if no string resource files are provided at runtime.
Localized Strings can be used any place where a string literal can be used, including form specification files.
LSTR()
operator dynamically loads a Localize String from the name passed as
parameter:DEFINE sid STRING = "Greetings"
DISPLAY LST(sid)
SFMT()
with
%nnn
parameter place holders, to build a string containing data
that is only known at runtime:LET rec.cust_num = 200
DISPLAY SFMT( %"cust.valid", rec.cust_num )
"cust.valid"="customer %1 is valid"
"customer 200 is valid"
Extracting strings
You can generate a Source String File by extracting all of the Localized Strings from your program module or form specification file, using the -m option of fglcomp or fglform:
fglcomp -m custlist.4gl > mystrings.str
"Greetings" = "Greetings"
"Greetings" = "Bonjour"
The source string file must have the extension .str.
Compiling string files
Compile the String files using the Compile File or application-level Build option in Genero Studio, or use the command line tool fglmkstr.
fglmkstr mystrings.str
The resulting Compiled String File has the extension .42s (mystrings.42s).
Deploying string files
The Compiled String Files must be deployed on the production sites. The file extension is .42s.
Specify the list of string files to be used at runtime, with entries in the
fglprofile
configuration file.
fglrun.localization.file.count = 2
fglrun.localization.file.1.name = "common"
fglrun.localization.file.2.name = "customer"
The current directory and the path defined in the FGLRESOURCEPATH
environment
variable, are searched for the .42s Compiled String Files.
For more details, go to the Localized Strings section in the Genero Business Development Language User Guide.