Change localization settings at runtime
Use the fgl_report_configureLocalization
function to change the
directory where the program seeks the translation files and to change the formatting pattern for
numerical data at runtime.
Change the language directory
Change the language directory in which the translation files (42s) are
sought with the
fgl_report_configureLocalization
function. The
names of the translation files (captions.42s and
mappings.42s) remain constant, regardless of what language
is selected. It is the directory that is changed by the API
call.$echo $FGLPROFILE
fglprofile
$cat $FGLPROFILE
fglrun.localization.file.count = 2
fglrun.localization.file.1.name = "captions.42s"
fglrun.localization.file.2.name = "mappings.42s"
$find translation_files
translation_files
translation_files/en
translation_files/en/captions.str
translation_files/en/captions.42s
translation_files/fr
translation_files/fr/captions.str
translation_files/fr/captions.42s
translation_files/common
translation_files/common/mappings.str
translation_files/common/mappings.42s
$cat test.4gl
MAIN
...
#select French translation
LET handler=configureReport(“translation_files/fr:translation_files/common”);
START REPORT invoice TO XML HANDLER handler
...
END MAIN
...
FUNCTION configureReport(resourcePath)
...
LET handler=fgl_report_loadCurrentSettings(“localizable_invoice.4rp”)
...
CALL fgl_report_configureLocalization(NULL,resourcePath,NULL,NULL)
...
RETURN fgl_report_commitCurrentSettings()
END FUNCTION
...
Change the formatting pattern for numerical data
Change the formatting pattern for numerical data at runtime with the
fgl_report_configureLocalization
function.$echo $DBFORMAT
$:,:.:
$cat test.4gl
MAIN
...
#select German number formatting
LET handler=configureReport(“:.:,:EUR”);
START REPORT invoice TO XML HANDLER handler
...
END MAIN
...
FUNCTION configureReport(numberFormat)
...
LET handler=fgl_report_loadCurrentSettings(“invoice.4rp”)
...
CALL fgl_report_configureLocalization(NULL,NULL,numberFormat,NULL)
...
RETURN fgl_report_commitCurrentSettings()
END FUNCTION
...