Show TOC Start of Content Area

Process documentation Internationalization Service  Locate the document in its SAP Library structure

Purpose

The internationalization service enables you to access language-dependent resources like messages or texts to be displayed in a UI element. It enables you to easily access these resources using the java.util.ResourceBundle class and the java.text.Format class.

Language-dependent resources – like the text of a UI element that can be translated – can be split into two types.

      Language-dependent resources that you specify at design time.
Texts that you assign to a UI element in the SAP NetWeaver Developer Studio are automatically passed to the property resource bundles and are then connected to the SAP translation process. This translation process provides additional resource bundles, which have a language key for the corresponding language. The naming convention is as follows: Resource + < Web Dynpro component name>_<language key>.properties - for example, ResourceTestComponent_en.properties.
A property resource bundle is created for each Web Dynpro component that uses a language-dependent text source. The bundle is called Resource + < Web Dynpro component name>.properties.
These resource bundle properties files are in the directory structure of the Package Explorer under /gen_wdp/packages in the Web Dynpro component package subdirectory <Web Dynpro component package>.

      Language-dependent resources that are used dynamically – that is, that are programatically specified in the source text of the Web Dynpro application.
If you want to use language-dependent resources for dynamic programming, the application programmer must ensure that these resources are entered in the corresponding resource bundles. You can also access the resource bundles that you created yourself using the interface of the internationalization service.

Recommendation

You should store all resource bundles of a Web Dynpro application in the same development component in which the Web Dynpro application is located. This avoids problems that might occur when a development component is updated. In addition, you should create only one resource bundle for all locally dependent resource bundles of a Web Dynpro application, because this reduces the maintenance effort required for the resource bundles.

Note

After you have created the resource bundle that is to support dynamically displayed messages, the application programming must manually import this resource bundle into the S2X translation system and the SAP NetWeaver Developer Studio. In the Web Dynpro Explorer, you open the directory /src/packages and import the resource bundle to the corresponding Java package.

You can also use the Message Editor for maintaining texts that are used dynamically. For more details on how to enter and edit messages, refer to Creating a Message.

Example

The following source code shows the methods provided by the IWDResourceHandler interface. that enable you to access the internationalization service:

Locale sessionLocale = WDResourceHandler.getCurrentSessionLocale(); 

IWDResourceHandler resourceHandler =
   WDResourceHandler.createResourceHandler(sessionLocale);

//or:

IWDResourceHandler secondResourceHandler =
   WDResourceHandler.createResourceHandlerForCurrentSession();

resourceHandler.loadResourceBundle( "com.sap.test.MyResourceBundle");

String saveMessage = resourceHandler.getString( "press_save" );

 

End of Content Area