!--a11y-->
Internationalization Service 
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 subdirectory /<Web Dynpro
component package>.wdp.
·
Language-dependent resources that are used
dynamically – that is, that are programmatically 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.

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.

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 to maintain texts that are used dynamically. For more information about entering and editing messages, see Creating a Message.
The texts in the resource bundle must exist in the ISO standard Latin 1 codepage. Other codepages must use Unicode characters.
The following source code shows the methods provided by the IWDResourceHandler interface, which allow you to access the internationalization service:
// All used classes of the internationalization service are contained in package // com.sap.tc.webdynpro.services.sal.localization.api
// Get the locale of the current session Locale sessionLocale = WDResourceHandler.getCurrentSessionLocale();
// Get the resource handler for the specified session locale by // using the factory class WDResourceHandler. IWDResourceHandler resourceHandler = WDResourceHandler.createResourceHandler(sessionLocale);
// Alternatively, use the following method: IWDResourceHandler secondResourceHandler = WDResourceHandler.createResourceHandlerForCurrentSession();
// 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 class loader that has // the package “com.sap.test” in its scope resourceHandler .loadResourceBundle( “com.sap.test.MyResourceBundle”, this.getClass() );
// get the message for the “press save” button String saveMessage = resourceHandler.getString( “press_save” );
|
