APEX_LANG

APEX_LANG

APEX_LANG.MESSAGE.png

APEX_LANG.MESSAGE API is great fit for translating messages in APEX. Here we can define a message for each desired language like en, fr etc.

MESSAGE function is very usefull to translate the messages or string returned from PL/SQL stored procedures, functions, triggers, packaged procedures, and functions.

Syntax

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,
    p_application_id  IN NUMBER   DEFAULT NULL)
RETURN VARCHAR2;
Parameter Description
p_name Name of the message as defined in Text Messages under Shared Components of your application in Oracle Application Express.
p0 through p9 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.
p_lang 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.
p_application_id Used to specify the application ID within the current workspace that owns the translated message you wish to return. Useful when coding packages that might be called outside of the scope of Oracle Application Express such as packages called from a database job.

Examples:

  • Define Message Shared Componants > Globalization > Text Messages

Text-messages

Define-messages

How to use APEX_LANG.MESSAGE ?

  1. Plain String
Select apex_lang.message(p_name=>'TEXT_MESSAGE') from dual;
  1. Specific language
Select apex_lang.message(p_name=>'TEXT_MESSAGE', p_lang=>'hi') from dual;
  1. With Substitution
Select apex_lang.message('MESSAGE_WITH_SUBSTITUTION', V('APP_USER')) from dual;

examples.png

  1. Test in Command Prompt
Select apex_lang.message('MESSAGE_WITH_SUBSTITUTION','Ashish ', p_application_id =>128 ) from dual;

Here Application id is 128 where i have created the Messages.

cmd-text.PNG

Demo


comments powered by Disqus