cancel
Showing results for 
Search instead for 
Did you mean: 

Internationalization - How obtain the preferred browser language?

Former Member
0 Kudos

Hi,

i have a webdynpro application in spanish and it is translated to english and portuguese too. I have two traductions

Translate 1 : views,simpletypes,messagePool (.xlf files)

Translate 2 : r3 data (descriptions, names...) I´m using RFCs to obtain data from R3 and i send the language in input parameters and R3 return me descriptions in the language passed.

My application has sap authentication, and i have the language from logged user.

But the problem is when the logged user has not a language predifined, then Translate 1 is in the first language in the preference of the browser (p.e. 'es'). i need this language to send it to R3 but i can not obtain it, i only can obtain the default Locale but i can not obtain the first language in the preferences of the browser.

i have used Locale class from Java, but it doesn´t help me.

Any idea?

Thank you

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi everybody,

thank you for your answers.

Definitely i have tested with Poojith's code:

java.util.Locale sessionLocale = WDClientUser().getCurrentUser().getLocale();

and with Manoj code:

WDResourceHandler.getCurrentSessionLocale().getLanguage();

and both solved the problem. They return me the first language of the preferred list of the

browser, but i have a question:

-In this moment the user has not a language predefined in sap(UME) and i have not permissions to change it, if a user has predefined language, do these codes return me the sap language or browser preferred language?

Thank you for all

Edited by: Fernando Acevedo on Oct 4, 2010 9:56 AM

Former Member
0 Kudos

Hi

I explicitly mentioned that whatever the code I gave you. With that you will get only preferred Browser Language. No matter is some language is maintained in SAP logon SU01 transaction. It will always return the Browser language...

Thanks,

Roshan

Former Member
0 Kudos

Hi Fernando -

For you problem following would be the solution - I have done this in PAR file so I am sharing that thing.. if u wanted to do the same in WD java.. then some modification will come but the concedpt will be the same..

IUserContext usrContext = request.getUser(); // get the user logined

java.util.Locale loc = usrContext.getLocale();

String usrLang = loc.getLanguage();

usrLang will always be the BROWSER language.

Cheers!

Roshan

Former Member
0 Kudos

Hi,

Use the following code:



WDResourceHandler.getCurrentSessionLocale().getLanguage();

The language preference is in the below order:

1. Logged in user language setting in the portal(UME).

2. From the browser Locale setting

3. JVM Locale

Hope it helps.

Regards,

Manoj

Former Member
0 Kudos

hello Fernando,

I faced some problems when the user change the language because they don't want the user change it through Explorer.

If you want to controll that changes use SAP POrtal and Single Sign On to mantain the language setted in backend (ECC for example).

former_member214651
Active Contributor
0 Kudos

Hi,

To get the language from Browser or UME setting use the following code:

java.util.Locale sessionLocale = WDClientUser().getCurrentUser().getLocale();

Regards,

Poojith MV