cancel
Showing results for 
Search instead for 
Did you mean: 

Change default language on browser thru WD Java

former_member300754
Participant
0 Kudos

hi all,

I already created .xlf for internationalization. The scenario is to display the page on the language regard to user's nationality. Do I have to create the BAPI to send the nationality of SAP user to let the WD Java knows the user's nationality? Or WD Java has any info about user's nationality?

In case I create BAPI to send user's nationality from SAP to WD Java, how can I set the default language on browser? Normally we have to set thru: Internat options => tab General => Languages to change the default language. If I want to set the language from WD Java, what the steps to do? Please advise me on this.

Thanks in advance.

Peerasit

Accepted Solutions (0)

Answers (2)

Answers (2)

siarhei_pisarenka3
Active Contributor
0 Kudos

>Do I have to create the BAPI to send the nationality of SAP user to let the WD Java knows the user's nationality? Or WD Java has any info about user's nationality?

This is not necessary. Logged in user working with WDJ has to be authenticated by AS Java (J2EE). User's settings in J2EE contains Language/Country/Timezone settings. You can edit the settings easily in Identity Management.

So WDJ internationalization (which means determination of the locale of a logged in user) goes through the following steps:

1) Take user's locale settings from J2EE UME (or Portal settings) if any.

2) If not determined - take user's IE locale settings.

3) If still not determined - take JVM default locale.

BR, Sergei

former_member300754
Participant
0 Kudos

// Set locale for default language on browser

// In this case, BAPI has been implemented to return 'TH' or 'EN'.


// @ ModifyView
  {
    //@@begin wdDoModifyView
	wdThis.setDefaultLanguage();    
    //@@end
  }

It's not working if setDefaultLanguage() is called at wdDoInit.


  //@@begin javadoc:setDefaultLanguage()
  /** Declared method. */
  //@@end
  public void setDefaultLanguage( )
  {
    //@@begin setDefaultLanguage()
	wdContext.currentZbapi_Get_Nationality_InputElement().setIv_Username(getIWDUser().getSAPUser().getName()); 
	wdThis.wdGetSLCMRegisPrintInvoiceController().executeZbapi_Get_Nationality_Input();
	
	try{
		if(wdContext.currentOutput_NatioElement().getEv_Nationality() != null){
			String lang = wdContext.currentOutput_NatioElement().getEv_Nationality();
			
			// Get default locale
			Locale locale = Locale.getDefault();
				
													
			if(lang.equals("TH")){
//			// Set the default locale to pre-defined locale
//				Locale.setDefault(Locale. THAI);				
			// Set the default locale to custom locale
				locale = new Locale("th", "TH");
				Locale.setDefault(locale);						
			}
			else{
			// Set the default locale to custom locale
				locale = new Locale("en", "EN");
				Locale.setDefault(locale);								
			}

		}
	}catch(Exception e){
		IWDMessageManager msgMgr =(IWDMessageManager) wdThis.wdGetAPI().getComponent().getMessageManager(); 
		msgMgr.raiseException(" Invalid locale : " + e.getMessage(),false); 
	}
	    
    //@@end
  }

Have a great day : )

Edited by: Peerasit Jomsri on Jul 18, 2009 2:01 AM

Former Member
0 Kudos

Changing the default locale of the VM sound like a very bad idea.

Armin

siarhei_pisarenka3
Active Contributor
0 Kudos

>Changing the default locale of the VM sound like a very bad idea.

+1

Former Member
0 Kudos

Hello,

I have exactly the same issue - I want the user to be able to select the language by clicking the link and the WD application would switch the content to that language automatically. This only works when I change the browser language settings and re-load. I tried the code you attached but it does not change the language. Are you sure this can be done in a WD app?

Thanks for your help,

Alex