cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent: Internationalization

Former Member
0 Kudos

Hi,

My exact requirement in internationalization is:

I have to select a country from the drop down list box and hit a 'Go' button to change the language to the selected country's language, instead of changing language settings from the browser.

Please help me in doing this.

Thanks much in advance.

Regards,

Srinivas.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

As far as WebDynpro application starts with specific locale and keep this locale for life-time what you need is to restart application with different locale.

See document http://help.sap.com/saphelp_nw04/helpdata/en/f4/651741f163f023e10000000a155106/content.htm for WD URL parameters.

So, in general you must implement the following algorithm:

1. Provide combo-box with Language(Key)->Country(DisplayValue) to user

-- In view create attribute <b>Locale</b> of type string

-- In wdDoModifyView add the following:


final String currentLocale = WDResourceHandler
  .getCurrentSessionLocale().toString();
    	
final IModifiableSimpleValueSet _svsLocales = wdContext
  .getNodeInfo()
    .getAttribute("Locale")
      .getModifiableSimpleType()
        .getSVServices()
          .getModifiableSimpleValueSet();
    					
final Locale[] locales = Locale.getAvailableLocales();
final int size = locales.length;
for (int i = 0; i < size; i++)
{
  final Locale locale = locales[ i ];
  _svsLocales.put( locale.toString(), locale.getDisplayCountry(locale) );
  /* Or display texts in current locale */
  /* _svsLocales.put( locale.toString(), locale.getDisplayCountry(currentLocale) ); */		
}
/* Highlight current locale */
wdContext.currentContextElement().setLocale
(
  currentLocale
);

2. Create necessary UI controls, bind DropDownByKey control to Locale attribute.

3. In "GO" button action handler place this code:


/* Pick selected locale */
final String locale = wdContext.currentContextElement().getLocale();
try
{
  /* Generate new URL for current application with locale arg */
  final String url = WDURLGenerator.getApplicationURL
  (
    wdComponentAPI.getApplication().getDeployableObjectPart(),
    Collections.singletonMap("sap-locale", locale)    
  );
  /* TO DISCUSS */
  /* Log-off current session and strat new one (with new locale)*/
  WDClientUser.forceLogoffClientUser(url);		
}
catch (final WDURLException ex)
{
  wdComponentAPI.getMessageManager().reportException
  (
    new WDNonFatalException(ex), false
  );
}

What I whant to discuss: firstly I try to implement redirection via exit plug. But current session was not destroyed and locale was not applied. The only way I found so far is to log-off user to new URL. This has one serious impact: in authorized applications user will have to log-in again just to change application locale.

Regards,

VS

Former Member
0 Kudos

Hi,

You can change the bind the Langugage fields to the Context elements. And on click of go u can insert appropriate unicode conversion in the context variable. Although I've not tried it out, hope this works ...

Or the crude way could be to create different Views coresponding to each language and change the View on click of go

VaibhaV

Former Member
0 Kudos

Hi Vaibhav,

Actually i didn't get your first point. But I tried loading resource bundle of the specific language(on action of button). But it didn't work.

If you are telling something different in your message from the above,it would be helpful if you explain it a bit briefly.

Regards,

Srinivas.

Former Member