22.6 Translating Applications

In any Oracle Reports Services application, you see many types of messages, including:

  • Error messages from the database

  • Runtime error messages produced by Oracle Reports Services

  • Messages and boilerplate text defined as part of the application

If the NLS_LANG environment variable is set correctly and the appropriate message files are available, then translation of messages for the first two items is done for you. To translate messages and boilerplate text defined as part of the application, you can use the Oracle translation tool, TranslationHub, and you might also find it useful to use PL/SQL Libraries for strings of code.


You'll find information about using TranslationHub on your Oracle Developer Suite documentation CD and on the Oracle Technology Network (http://www.oracle.com/technology/index.html).

Manual translation is required for constant text within a PL/SQL block because that text is not clearly delimited, but is often built up from variables and pieces of strings. To translate these strings, you can use PL/SQL libraries to implement a flexible message structure.

You can use attachable PL/SQL libraries to implement a flexible message function for messages that are displayed programmatically by the SRW.MESSAGE built-in procedure, or by assigning a message to a display item from a trigger or procedure. The library can be stored on the host and dynamically attached at runtime. At runtime, based on a search path, you can pull in the attached library. For example, a library might hold only the Italian messages:

FUNCTION nls_appl_mesg(index_no NUMBER)
   msg CHAR(80);
   IF index_no = 1001 THEN
      msg := 'L''impiegato che Voi cercate non esiste...';
   ELSIF index_no = 1002 THEN
      msg := 'Lo stipendio non puo essere minore di zero.';
   ELSIF  ...
      msg := 'ERRORE: Indice messaggio inesistente.';
   END IF;
   RETURN msg;

A routine like this could be used anywhere a character expression would normally be valid. For example, to display text with the appropriately translated application message, you might include the following code:



For a description of the SRW built-in package, including the SRW.MESSAGE built-in procedure, see the Oracle Reports online Help.

To change the application to another language, simply replace the PL/SQL library containing the nls_appl_mes function with a library of the same name containing the nls_appl_mesg function with translated text.