In order to internationalize an existing application, follow this
process:
- 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 (i.e. translated).
- In .per sources LAYOUT section,
replace hard-coded form elements like text labels by static LABEL form
items and define the TEXT attributes with
a % prefix in the ATTRIBUTES section.
- 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 localized strings
could be used as is, but it's better to define a normalized
identifier for each string, by using ASCII characters only. For
example, replace:
"Customer List" = "Customer List"
with:
"customer.list.title" = "Customer List"
- In sources, replace the original string text 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
(these should be ASCII now, so the locale should not matter).
- Compile the .str files in the locale used
by these files, and check whether the application displays
the text properly.
- Copy the existing .str files, and translate
the string text into another language (making 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.
A set of .42s files
using the same language and codeset is typically copied
in a distribution directory with a name identifying the
locale.
For example:
/opt/app/resource/strings/en_US.iso8859-1
-- English strings in iso8859-1 code-set
/opt/app/resource/strings/fr_FR.iso8859-1
-- French strings in iso8859-1 code-set
/opt/app/resource/strings/jp_JP.utf8
-- Japanese strings in utf-8 code-set
Future edits to the .per and .4gl source
files should be done in the ASCII locale, and .str string
files must be edited with their specific locale.