SetLanguage function
Syntax
SetLanguage(language_code)
Description
Use the SetLanguage function to set the end user's current language preference to the specified language_code. language_code must be a valid translate value for the field LANGUAGE_CD. SetLanguage returns True if it is successful, and it returns False if it fails or an invalid value was passed. The new language preference is temporary, remaining in effect only until the user logs off, or until another call is made to SetLanguage.
Note:
SetLanguage does not work in Signon PeopleCode, or with asynchronous messages.
Parameters
| Parameter | Description |
|---|---|
|
language_code |
A valid language code, stored in the Translate table for the LANGUAGE_CD field. |
Returns
Optionally returns a Boolean value indicating whether the function executed successfully. Returns False if an invalid language code is passed.
Example
The following example switches the language code and displays a message informing the end user of the change:
If SetLanguage(LANGUAGE_CD) Then
WinMessage(MsgGet(102, 5, "Language preference changed to ", LANGUAGE_CD));
Else
WinMessage(MsgGet(102, 6, "Error in setting language. Language is currently⇒
%1", %Language));
End-if;
Considerations Using SetLanguage With %Language
The value of %Language depends on the type of application:
-
For online applications, %Language is the language code that the current component is using.
-
For non-online applications (such as in an application engine program), %Language is the language code of the user based on their language preference in their User Profile.
SetLanguage changes the default language for the current session only. The language change does not take effect until the component buffer is flushed and repopulated. For example, transferring to a new component causes the buffer to be flushed.
%Language reflects the value using SetLanguage after the function is executed.
SetLanguage changes the current user interface and data language simultaneously. If the Multi Language Entry personalization option is enabled, users can change the data language independently from the user interface language. There is no way to change the data language from PeopleCode without also changing the user interface language using SetLanguage.
Related Topics