Creating Multilanguage User Interfaces SAP ABAP Web Dynpro

We create a simple WD component,where we use some of the above-mentioned tools to offer support for English and German without making any code changes.All we have to do is to translate certain centralised strings and,after changing the log-on language(in our case,from“en”to“de”),the data will be automatically shown in the respective language.The WD component structure is presented.

WD component structure

In the context view,we create a context node named PERSON, Cardinality 1...1,Singleton,dictionary structure YPERSON and a context attribute named TEXT_I18N of STRING type.The context view and the view layout are presented.

Context node and view layout

We didnt insert any static strings for the“text”property of the UI elements Label and Button,or for the Caption view element.The strings shown as labels for the InputField UI elements represent the texts from the label field of the elementary data elements created in the ABAP Dictionary.For example,the label with the ID “FIRSTNAME_LBL” represents the label for the InputField bound to the attribute FIRSTNAME.The data element for this attribute is YPERSON-FIRSTNAME.If we look in our table definition,we can see that the elementary data type is YFIRSTNAME.. it can be seenthat“text”property of the label FIRSTNAME_LBL doesn’t contain anystatic values.To establish this string, we use the text with thelength Medium,defined in the YFIRSTNAME data element,i.e.“First Name”.

Text property and elementary data elements

Internationalization of Data Elements Defined in ABAP Dictionary

To internationalized data element defined in ABAP Dictionary, we have to translate the corresponding texts.The way we can perform this translations.

Translating the texts from a data element

After this,a pop-up window asks the language in which we want to translate the texts.We choose German and we enter the texts to be translated,for the strings.We repeat the same steps,until all the strings for the corresponding elementary data elements are translated.

Translating the strings

Internationalization of Domains Defined in ABAP Dictionary

Similarly,we translate the texts stored in our Domain Y_COUNTRY_DOMAIN.

English–German translation for a domain

Translating the domain fixed values

Internationalization of Text from OTR

In our example,we have to enter a value in the text property of the UI element Button.To do this,we choose the OTR text that exists in theSOTR_VOCABULARY_BASIC package.

The OTR text from the SOTR_VOCABULARY_BASIC package

To create our own OTR text,we can use the menu Goto Online Text Repository Browser or the transaction SOTR_EDIT Editor for OTR texts. Figure shows how we can create an OTR text by using the Online Text Repository Browser.

Creating OTR texts

The basic vocabulary stored in the SOTR_VOCABULARY_BASIC package can be used for all the packages,but the created OTR textsare stored only once per each package.

Our own-defined OTR text

To translate an OTR text,we can use the transaction SE63 Translation: Original Screen.After translating it,we can use our own defined OTR text in the same way as the OTR texts defined by SAP in the SOTR_VOCABULARY_BASIC package.Then,we have to create a Multilanguage text for the text property of the Caption element.

Internationalization of Text from Assistance Class

In the previous chapter,we have seen how we can use an Assistant Class to work with messages. In this case,we use the texts stored in the text pool of the assistance class to make Multilanguage our text required by the Caption view element.We create an assistance class named YCL_I18N.We define here the text to be made Multilanguage.

Texts from assistance class

In the field mLen,we have to specify the maximum length of the text string of a text symbol.As we have already seen,this value should be greater than or equal to the defined length(dLen).It is better to use a higher value,because,at design time,we don’t knowfor how many languages we offer support.In English,forexample,the length is 36,but when we translate this string in another language,it might be greater.In this case,we could not be able to enter the entire translation text.This length is saved in the text pool.To translate this text from English into German,we use the menu Goto->Translation.

Translating texts from the assistance class

After this,we realise a data binding between the attribute TEXT_I18N and the property text of the Caption element.We dynamically access the string we have just defined and translated.

wdDoInit( )Hook method

As we have mentioned above,to be able to have access to the text symbols of the assistance class by using the instance attribute WD_ASSIST,we have to assign the assistance class to our component.After this,we run our application.

Runtime. Default language: English

Internationalization of Messages

We create a Message class named YCL_I18N_MSG,where we define a message with the ID“000”and the short text “First Name is nrequired!”We want to show this message when the user presses the Update button.

Runtime – German

To translate this message,we choose from MENU Goto -->translation.

Translating a short text in the message class

When the user presses the Upload button,the Framework triggers the even handler method onactionsave. We run our application in the original language English and in German.

The onactionsave event handler method

Multilanguage messages



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

SAP ABAP Web Dynpro Topics