Steps for application internationalization
Follow these steps to internationalize your application.
- Identify the current character set used in your sources and make sure the application locale (LANG/LC_ALL) is set correctly.
- In .4gl sources, add a %
prefix to the strings that must be localized (translated). For parameterized messages,
replace concatenated strings by a
SFMT()
usage with%n
placeholders for variable message parts. - In .per sources
LAYOUT
section, replace hard-coded form elements like text labels with staticLABEL
form items and define theTEXT
attributes with a % prefix in theATTRIBUTES
section. - In XML resources, add
<LStr />
elements under the elements where text attributes must be localized. - Extract the strings from the .4gl sources with fglcomp -m and use fglform -m for .per sources.
- Organize the generated .str source string files (identify duplicated strings and put them in a common file).
- At this point, the string identifiers (on the left) are the same as the string texts (on the
right). These string identifiers can be used as is, or can be changed to clear ASCII identifiers
such as
"customer.list.title"
. Using simple identifiers allows you to distinguish strings depending on the context and use ASCII encoding for your sources. Keeping string identifiers with the original text requires no source changes (except adding the % prefix), but makes sources dependent to a locale: If you want to support multiple languages, you must use UTF-8 in sources and at runtime. - When using simple ASCII identifiers, replace original strings with the new string identifiers. Strings to be replaced can be located by their % prefix. You can, for example, use a script with an utility like the sed UNIX™ command to read the .str files and apply the changes automatically.
- Recompile the .4gl and .per sources (when using simple ASCII strings identifiers, sources are expected to be full ASCII now).
- Compile the .str files in the locale used by these files,
- Setup FGLPROFILE
fglrun.localization.*
entries, to let fglrun find the string resource files. - Run your programs to check whether the application displays the text properly.
- Copy the existing .str files, and translate the string text into another language (make sure the locale is correct).
- Compile the new .str files, and copy the .42s files into another distribution directory, defined with the FGLRESOURCEPATH environment variable.
- Run your programs again, to check that texts and labels of the other language are displayed.
- Next changes to the .per and .4gl source files are done in the ASCII locale, and .str string files must be edited with their specific locale.