Oracle® Application Express API Reference Release 3.2 E12510-02 |
|
|
PDF · Mobi · ePub |
You can use APEX_LANG
API to translate messages.
Topics in this section include:
This function is used to return a translated text string for translations defined in dynamic translations.
APEX_LANG.LANG ( p_primary_text_string IN VARCHAR2 DEFAULT NULL, p0 IN VARCHAR2 DEFAULT NULL, p1 IN VARCHAR2 DEFAULT NULL, p2 IN VARCHAR2 DEFAULT NULL, ... p9 IN VARCHAR2 DEFAULT NULL, p_primary_language IN VARCHAR2 DEFAULT NULL) RETURN VARCHAR2;
Table 11-1 describes the parameters available in the APEX_LANG.LANG
function.
Parameter | Description |
---|---|
|
Text string of the primary language. This will be the value of the Translate From Text in the dynamic translation. |
|
Dynamic substitution value: p0 corresponds to 0% in the translation string; p1 corresponds to 1% in the translation string; p2 corresponds to 2% in the translation string, and so on. |
|
Language code for the message to be retrieved. If not specified, Oracle Application Express uses the current language for the user as defined in the Application Language Derived From attribute. See also: Specifying the Primary Language for an Application in the Oracle Application Express Application Builder User's Guide. |
Suppose you have a table that defines all primary colors. You could define a dynamic message for each color and then apply the LANG function to the defined values in a query. For example:
SELECT APEX_LANG.LANG(color) FROM my_colors
If you were running the application in German, RED was a value for the color column in the my_colors
table, and you defined the German word for red, the previous example would return ROT.
Use this function to translate text strings (or messages) generated from PL/SQL stored procedures, functions, triggers, packaged procedures, and functions.
APEX_LANG.MESSAGE ( p_name IN VARCHAR2 DEFAULT NULL, p0 IN VARCHAR2 DEFAULT NULL, p1 IN VARCHAR2 DEFAULT NULL, p2 IN VARCHAR2 DEFAULT NULL, ... p9 IN VARCHAR2 DEFAULT NULL, p_lang IN VARCHAR2 DEFAULT NULL) RETURN VARCHAR2;
Table 11-2 describes the parameters available in the APEX_LANG.MESSAGE
function.
Parameter | Description |
---|---|
|
Name of the message as defined in Shared Components > Text Messages of your application in Oracle Application Express. |
|
Dynamic substitution value: p0 corresponds to 0% in the translation string; p1 corresponds to 1% in the translation string; p2 corresponds to 2% in the translation string, and so on. |
|
Language code for the message to be retrieved. If not specified, Oracle Application Express uses the current language for the user as defined in the Application Language Derived From attribute. See also: Specifying the Primary Language for an Application in the Oracle Application Express Application Builder User's Guide. |
The following example assumes you have defined a message called GREETING_MSG in your application in English as Good morning%0 and in German as Guten Tag%1. The following example demonstrates how you could invoke this message from PL/SQL:
BEGIN ---- Print the greeting -- APEX_LANG.MESSAGE('GREETING_MSG', V('APP_USER')); END;
How the p_lang
attribute is defined depends on how the Application Express engine derives the Application Primary Language. For example, if you are running the application in German and the previous call is made to the APEX_LANG.MESSAGE
API, the Application Express engine first looks for a message called GREETING_MSG
with a LANG_CODE
of de
. If it does not find anything, then it will revert to the Application Primary Language attribute. If it still does not find anything, the Application Express engine looks for a message by this name with a language code of en-us.