Internationalization Service
Use
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 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.
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" ); |