Internationalization is the process by which the language-specific parts of a program are separated from the other parts. A central aspect of internationalization (I18N) is the translation of texts that are used, for example, to label user interface elements or display messages on user interfaces.
To separate the language-specific text elements from the source code, the Java programming language provides the classes java.util.ResourceBundle and java.text.format, which are also used in Web Dynpro for the internationalization of a Web Dynpro application and are included in the WDResourceHandler class. The Java class PropertyResourceBundle, which is derived from the ResourceBundle class, is used to isolate the language-specific resources (text elements) and store the contents in properties files. To process these properties files, the translator does not require any Java knowledge. However, properties files cannot be translated directly. They are converted into the S2X format using the tool S2X Document Editor and filled with additional context information. The properties files can be passed to the translation backend as S2X files. Usually, the files are transferred automatically during the release or consolidation of a development in the development system. A copy of each released S2X file is also transferred to the translation process. When the translation is completed, the translation backend returns a localized S2X file for each S2X source file and target language to the SAP NetWeaver Developer Studio. If the original S2X source file originates from a properties file, an additional properties file is generated for each localized S2X file. The returned localized files (S2X files and property files) are checked into the development system and immediately released for delivery or consolidation.
This means that the translation is consolidated automatically, with a delay compared to the primary development. The standard management service processes are used for the distribution logistic, including the build and deployment process. The same applies for the post-processing of texts in objects that already passed the translation process.
For further information about the S2X Document Editor, refer to Internationalization.
For information about translation management in the translation backend, refer to the SAP Library under ® SAP NetWeaver Components ® SAP Web Application Server ®Documentation Tools and Translation Tools.
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
# DO NOT MODIFY! CHANGES WILL BE LOST IF THE FILE IS REGENERATED
# 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!
The source code of the last line assigns the value “Hello World!” to the text property of the UI element TextView with the name “DefaultTextView”, which is in the view “TestViewInternationalization”.
If you use translated properties files, you do not need to compile the application again. At runtime, the relevant properties file is loaded dynamically, depending on the language ID of the current user.
An internationalized program contains no language specific text elements in the source text. As already mentioned, these elements contain error messages and texts that are used to label UI elements. These text elements are defined outside the application and grouped into isolated resource bundles by the application.
Within Web Dynpro, the language-specific text elements are divided into three types:
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 WDResourceHandler class, 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” );
· The creation of language-specific properties files using the Message Editor
· The modification of S2X files already created or the conversion of properties files into S2X files using the S2X Editor. The S2X Editor allows you to add context information to S2X files that is essential for the correct translation of the text elements.
In this way, this process simplifies 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.