SAP puts a very strong emphasis on multilingual applications. So if you ever wondered how to make your Web Dynpro application multilingual this is a small how-to Weblog for you. I explain how to make your application multilingual without the need to set up a translation infrastructure (which is still to come but will make everything simpler).
Generate Language Files
But at first you will not see any of these resource files because the resource file generator only runs when you right-click on the project and choose “Create Archive”. If I have a Web Dynpro component named
located in the package
and project language set to English, a resource file will be generated for everything inside the component with the name
in the Java package
. Open it and you will see some very simple key value pairs like this:
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 FlightSearchComp
view.FlightSearchListView.Table_14.Column.Table_14_Seatsmax.Header.text = Seatsmax
view.FlightSearchListView.Button_15.text = back
view.FlightSearchListView.Table_14.Column.Table_14_Airpto.Header.text = Airpto
view.FlightSearchListView.Table_14.Column.Table_14_Airpfrom.Header.text = Airpfrom
What would I need to do to translate this file into German?
I need to create a resource file with the same name but ending
in the same Java package. Then I would need to learn German and put the translated values with the same keys into that file. Let’s go through it step by step.
folder we create a Java package named
. Then we copy the ResourceMyComp_en.properties to that location. There we rename the file to
. Then we can open the file and translate the values into German.
The reason we don’t leave the properties file in the gen_wdp folder is because everything that stays there gets deleted next time code the project is rebuild. But in the
folder everything is safe and will be included in the distributable archive.
That’s it! We’re ready to test. First we need to configure our browser for a different language. This browser language is transmitted through an http header and Web Dynpro application chooses the correct language file according to the browser language, or according to the specified language of the user if the application uses authentication. To configure the browser we open our Internet Explorer and choose in the menu item Tools/Internet Options . There is a button
where we can add the desired language to our browser. You should put the desired language at the top of the list and close all browser windows to put the changes into effect. You can now “Deploy and Run” your application and it should show in German!
In general I would recommend not to translate your application until it is pretty much finished. Otherwise you always have to keep the resource bundle files in sync.
You learned how to add a different language to your Web Dynpro application by creating a new resource bundle file. You were able to test it by changing the language setting of your browser. We did not touch the issue of messages that are used in the program code. For this you should add messages in the message editor and call the defined keys in your code instead of hard coding the strings. How to do that is explained in detail in the
SAP Netweaver Studio help
and in the Java API documentation for
This is a workaround for version SP2 of the Netweaver Studio. In SP3 and later versions you may copy and translate the
files in the
directly because then the
files are generated for every
file. But even this should not be necessary anymore once the translation infrastructure is in place.