Crystal Reports: getLocalizedString() Function

getLocalizedString is a Crystal Reports Custom Function to used convert a constant to a localized string.

//Purpose: Convert a constant value to a localized string
//Parameters: Key -
// Lang - ISO language string
//Returns: localized string
Function (Stringvar Key, Stringvar Lang)
//define array of keys that are used by Formula fields
Stringvar Array Keys:=["COUNTRY","REGION","CITY"];
//define arrays of localized strings for each required language in the same position as the Key array
Stringvar Array Values;
Select Lang
Case "en_US": Values:=["Country","State","City"]
Case "it_IT": Values:=["Paese","Dichiari","Città"]
Case "fr_FR": Values:=["Pays","état","Ville"]
Default: Values:=["Country","State","City"]
//End Select
//iterate through Key array...
Numbervar i;
Stringvar value;
for i := 1 To Ubound(Keys) do (
//if value in array matches the specified value, return the value from the localized array
if Keys[i] = Key then
exit for
//end if
//return result


The abstract value.
The ISO language string

Return Value

A string


Crystal Reports XI introduces a new keyword named ‘ContentLocale’. This property returns the machine’s locale setting, usually found in the Control Panel’s Regional Settings (e.g. en_US for English (US)). However, this keyword can only be used in formulae that are excuted during the report’s ‘Second Pass’ (see Crystal Reports: Report Processing Model). The following Record Selection Formuala, for example, will generate an error:


ContentLocale can be used in combination with a Report Custom Function to dynamically and transparently apply localization settings when a report is viewed, even reports that have been saved with data or have been scheduled using Business Objects Enterprise.


//if the workstation's ContentLocal is Italian (Italy), then the following will return 'Paese'
getLocalizedString ("COUNTRY",ContentLocale)


This function requires the use of Crytal Syntax.

2 thoughts on “Crystal Reports: getLocalizedString() Function

Leave a Reply

Your email address will not be published. Required fields are marked *