Start of Content Area

Component documentation Internationalization of Web Dynpro Projects  Locate the document in its SAP Library structure

Use

To separate language-dependent text elements from the source code, Web Dynpro uses the Java classes java.util.ResourceBundle und java.text.format. The Java class PropertyResourceBundle, a class derived from the class java.util.ResourceBundle, serves to isolate the language-dependent resources (text elements) and to store their contents in language-specific properties files. For an example of a properties file, refer to the one shown below. This enables you to develop source code that does not contain language-specific texts and therefore does not dependent on the language key used. You can develop Web Dynpro applications that can be easily internationalized and translated into several languages.

At runtime, the relevant properties file is loaded dynamically, depending on the language ID of the current user.

Use

An internationalized program contains no language-specific text elements in the source text. These elements include error messages and texts that are used to label UI elements. The text elements are defined outside the application and grouped into isolated resource bundles by the application. If you use translated properties files, you do not need to compile the application again.

Within Web Dynpro, the language-specific text elements are divided into three types:

Furthermore, the SAP NetWeaver Developer Studio supports the following:

·        The creation of texts and messages that are added to the properties file using the Message Editor

·        The modification of S2X files already created using the S2X Document Editor

·        The conversion of properties files into S2X files and vice versa The S2X Editor also allows you to add context information to S2X files that is essential for the correct translation of the text elements.

These Web Dynpro tools simplify the process of the creation of international applications and hence the translation process of the language-specific resources.

You can therefore develop applications that suit different languages without having to recompile an application for each individual language when a new language is to be supported.

The Internationalization Service of the Web Dynpro Runtime Services supports this PropertyResourceBundle concept and allows easy access to the classes java.util.ResourceBundle and java.text.format. With the class com.sap.tc.webdynpro.services.sal.localization.api.WDResourceHandler, you can read the language-specific text elements using the following source code:

// Load the resource bundle “MyResourceBundle.properties” located
// in the package “com.sap.test” for locale set in the resource handler.
// Therefore, the resource handler also needs the classloader that has
// the package “com.sap.test” in its scope
resourceHandler.loadResourceBundle(“com.sap.test.MyResourceBundle”, this.getClass() );
// get the message of the “press save” button

String saveMessage = resourceHandler.getString( “press_save” );


 

Example of a Properties File

A properties file contains simple name/value pairs for a specific language ID, as the following example of a properties file ResourceTest.properties (generated automatically by the SAP NetWeaver Developer Studio) shows:

# ---------------------------------------------------------------------------

# This file has been generated by the Web Dynpro Code Generator

# DON'T MODIFY!!! CHANGES WILL BE LOST WHENEVER THE FILE GETS GENERATED AGAIN

# ---------------------------------------------------------------------------

 

 

# Resource bundle for Test

 

 

# message pool

message.error1 = Runtime error

message.warning1 = You have to re-deploy your application!

 

# view TestViewInternationalization

view.TestViewInternationalization.DefaultTextView.text = Hello World!

 

For further information about the handling of texts declared at design time, refer to Determining Language-Dependent Resources at Design Time.

 

Additional Information

Refer also to the tutorial Developing International Web Dynpro Applications, if you wish to program a Web Dynpro application that is to be made available in several languages.

 

End of Content Area