You create a dynamic translation to translate dynamic pieces of data. For example, you might use a dynamic translation on a list of values based on a database query.
Dynamic translations differ from messages in that you query a specific string rather than a message name. You define dynamic translations on the Dynamic Translations page. You then use the APEX_LANG
.LANG
API to return the dynamic translation string identified by the p_primary_text_string
parameter.
You define dynamic translations on the Dynamic Translations page. A dynamic translation consists of a translate-from language string, a language code, and a translate-to string.
To define a dynamic translation:
Navigate to the Translate Application page:
On the Workspace home page, click the Application Builder icon.
Select an application.
Click Shared Components.
Under Globalization, click Translate Application.
On the Translate Application page, select Optionally identify any data that needs to be dynamically translated to support SQL based lists of values.
On the Dynamic Translations page, click Create and specify the following:
Language - Select a target language.
Translate From Text - Enter the source text to be translated.
Translate To - Enter the translated text.
Click Create.
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 18-5 describes the parameters available in the APEX_LANG
.LANG
API.
Table 18-5 APEX_LANG.LANG Parameters
Parameter | Description |
---|---|
|
Text string of the primary language. This is the value of the Translate From Text in the dynamic translation. |
...
|
Dynamic substitution value: |
|
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" |
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
.