Multi-Language Management in Java Applications

This chapter describes Java-specific customizations of multi-language management.

Detailed information on the multi-language management is provided in Multi-Language Management


Defining the Language at Runtime

With the protected member m_sessionContext, you find or set the currently active language used by the multi-language management:

...
m_sessionContext.setLanguage("de");
...

The value passed to the session context is only valid within the context of current session. Therefore, different users can be logged on to the system choosing different languages.

The string, which is passed to the setLanguage() method of m_sessionContext, represents the name of the directory in which the CSV files are stored. You are not bound to the "de" and "en" directories; you can add any other directories representing additional languages.

Dealing with Literals inside Your Adapter

Use method replaceLiteral of the inherited Adapter class to replace messages:

...
this.outputMessage("S",replaceLiteral("APP1","successFileSaved"));
...

The first parameter is an abbreviation - the file name of the multi-language file. The second parameter is the text ID that should be translated into text as described previously.

It is also possible to pass parameters of your application to the multi-language management. For example, if you want to show a success message which informs that file "xyz" was saved, proceed as follows:

...
String fileName = "xyz";
this.outputMessage("S",replaceLiteral("APP1","successFileSaved",fileName));
...

The corresponding line in the CSV file (APP1.csv) in the \en directory for English looks like:

...
successFileSave;File &1 was saved successfully
...

The "&1" is automatically replaced with the file name. There are other variants of the replaceLiteral() method available to pass 2 or 3 parameters. In this case, use &1, &2 and &3 in the text definition.