Change localization settings at runtime

Localization information (FGLPROFILE, FGLRESOURCEPATH, DBPATH, DBFORMAT and so on) are statically defined at the start of a program and cannot be changed at runtime. However, by placing reports in separate executables and running these from the main application with a modified environment, you can achieve the affect of “modifying” these values on a per report basis.

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 in which the files are sought that are changed via 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
...