cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic change the browser language

Former Member
0 Kudos

Hi people,

I want to change dynamically the language of my webdynpro application. I followed the steps described in the thread

When I start a new browser window (IExplorer 6.0) and I enter the URL of my application with the url parameter sap-locale="de_DE" or sap-locale="en_US" the application starts in the desired language. Fine!

But if I terminate the application like described in the thread

final String locale = wdContext.currentContextElement().getDropDown();

try

{

final String url = WDURLGenerator.getApplicationURL(

wdComponentAPI.getApplication().getDeployableObjectPart(),Collections.singletonMap("sap-locale", locale));

WDClientUser.forceLogoffClientUser(url);

// IWDWindow w = wdComponentAPI.getWindowManager().createExternalWindow(url, "hjhj", false);

// w.open();

}

catch (final WDURLException ex)

{

wdComponentAPI.getMessageManager().reportException(new WDNonFatalException(ex), false);

}

the application restarts, but without changing the language, even if the URL has the URL parameter sap-locale set.

Is this a bug of the browser (is the language cached?)? Any idea how the change the language of the appliaction, out of the application itselfe?

Thanks for your help!,

Thanks

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member1
Active Participant
0 Kudos

Hi,

Check out this thread.

<a href="/people/abdulbasit.gulsen/blog/2007/02/21/multilingual-external-facing-portal-with-different-contents Capability</a>

Hope it ll b of help

Regards,

Anish

Former Member
0 Kudos

Have you tried setting your preferred language in the <i>browser</i> ?

<blockquote>

IExplorer: Tools>Internet Options>Languages

</blockquote>

I feel this method is the least intrusive for the user, as his/her language preference will usually be set not just for your app, but for any site he/she visits.

<p>

However, if you wish to change languages, you need to be aware of the fact that you might need to close your browser, modify your language preferences, and then start a new session .

<p>

Hope this helps.

luciano_leitedasilva
Contributor
0 Kudos

Thomas,

There is another solution, but with a bigger impact. Did you think about change the user attribute language at the UME before close the application? This solution will work.

Regards,

Luciano

Former Member
0 Kudos

How can I change the users attribute language at the UME out of the application? I find only the getter methods in the objects:

-WDClientUser.getCurrentUser()

-WDClientUser.getCurrentUser().getSAPUser()

What do you mean with another solution, with a bigger impact?

Thanks,

Thomas

former_member182372
Active Contributor
0 Kudos

Hi Thomas,

You can get reference to IUser through WDClientUser.getCurrentUser().getSAPUser()


try 
{
	IUserFactory userFactory = UMFactory.getUserFactory();

	IUser user = WDClientUser.getCurrentUser().getSAPUser();
	IUserMaint userToChange = userFactory.getMutableUser(user.getUniqueID());
	 
	Locale newLocale = //get new locale;
	 
	userToChange.setLocale(newLocale);
	userToChange.commit();
} 
catch (Exception e) 
{ 
//report
}

Best regards, Maksim Rashchynski.

luciano_leitedasilva
Contributor
0 Kudos

Hi Thomas,

Have a look at the below code:

IWDClientUser wdUser = WDClientUser.getCurrentUser();

IUser user_wd = wdUser.getSAPUser();

String userId = user_wd.getUniqueID();

IUserFactory userFactory = UMFactory.getUserFactory();

IUserMaint user = userFactory.getMutableUser(userId);

String lang = "es";

user.setLocale(new Locale(lang,"",""));

user.save();

user.commit();

This code will change the user language attribute at the UME. The bigger impact is because this change will impact all applications over the landscape. I.E. If the web dynpro application change the user language at the UME, this change will be reflected at the Portal.

Regards,

Luciano

Former Member
0 Kudos

Thank you for your answers, but I have still the same problem. The recommendation of changing the sap-users language attribute doesn't work, because I'm working with an application without authententication.

I tried to exit the application with an exit-plug, passing the url http://<host>:<port>/webdynpro/dispatcher/local/TestLanguage/TestApp?sap-locale=en_US, without success.

If I start the application with this url in a new browser window, the application is starting in english. If I start the application in german and then call the same url through the exit-plug the application remains in german. This must be a browser problem, mustn't?

Any help appreciated,

Thomas

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Thomas,

this is a known restriction in Web Dynpro. The locale of a running Web Dynpro application is associated with the Client Session. And client session is associated with the client window. This means starting a new client window (adressing the same WD application with another sap-locale-URL-parameter value) will not affect the session locale of the adresses application.

The only workaround is to start a new Web Dynpro application (requiring <b>no</b> authentication) by "running the browser programm from scratch", this means not keeping the existing browser window open and then selecting menu item "new window" or opening the target application in a new external window. You must either close the window with the running application and then start a new browser window or you must open a new browser program via a task bar icon or the start menu (i.e. run <browser program>.exe again).

<b>Consequence (NW04 / NW04s)</b>

<i>For your specific requirement "restarting a running Web Dynpro application without authentication in another session locale" can only be achieved by running the <browser program>.exe again. Running another window instance in the same client session will not affect the initial session locale.</i>

Regards, Bertram

Former Member
0 Kudos

Thank you for the answer.

So I understood, that it isn't possible the change the language out of the application. in webdynpro I have not the possibility to start a new instance of the browser, don't I have?

Regards,

Thomas

Former Member
0 Kudos

No idea where the problem may be?