cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Internationalization / Localization

Former Member
0 Kudos

Hello!

We have MII work centers on the manufacturing floor that run under "dummy" accounts (ex: workcenter1 login). That login is set to use a language setting of "es" (Spanish). We have many different users throughout the day who clock in and out of the MII application, but the single dummy account is who is actually logged in. Meaning: each workcenter user does not login / logout throughout the day. The application stays running under the dummy account.

I have a requirement to allow users to change the language setting within the application as they see the need. In the example above - the default setting is Spanish, but maybe that particular user is more comfortable reading English. They need to be able to, on the fly, set the new language and have the page render correctly.

I have defined 2 bundle files: MII_en.properties and MII_es.properties and placed a few label names inside each. If I change the dummy user's language preference in their account and log out and log back in under that dummy account, the new language takes affect as I'd expect. The labels are read from the correct bundle file.

However, if I try to programmatically, within the MII application, set the session variables for Language, Country, locale and Locale - it has absolutely no effect on the page or resource bundle that's chosen! I always see the labels as they were when the user logged in.

In "normal", non MII, web development (think: Java/Spring/JSP stack), I can create a dropdown list for the user to choose their session language dynamically and refresh the page. The correct resource bundle gets picked up and the language renders correctly. I don't need the user to log out and log back in.

Is this same functionality not available in MII? Am I required to have the user log out and log back in?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

You may also be able to append the following parameter to the page URL in order to force it to be overridden when loaded:

&Language=es

Sam

0 Kudos

All of the applet objects also have the setPropertyValue(Name, Value) JavaScript function.

Sam

Former Member
0 Kudos

Do you have an example code snippet of doing that? I don't think we're using applets...just .irpt files with HTML, CSS, JS and some XSL translations of data sets.

swaroop_anasane
Active Contributor
0 Kudos

Hi Brian,

Would like to bring about a point. The sequence in which locale would be picked:

1.  user language

2.  system language

3.  English (EN)


You may want to check if you are setting user language properly, though i don't believe dynamic switching would help.


I would suggest you implement localization using UI5 localization feature where in you can register specific resource file on user events.


Thanks,

Swaroop

0 Kudos

Swaroop,

In MII we manage the property file definitions already (see my previous comment on how and where this is done) so how would this be "registered" with the UI library?

Sam

Former Member
0 Kudos

Hi Swaroop!

That's great information on the ordering of language settings. That would explain why my setting the session variable for the current user had no impact on the language.

Overall it sounds like MII / Netweaver works in a completely different, closed way than standard web application development. There's really no way, using the SAP APIs that this can be done...without installing UI5.

In the meantime, I have resolved this by implementing a client-side solution using the jQuery.i18n.properties.js API. I have the resource bundles defined in the "Web" part of my MII project, and the user can switch language on the fly (dynamically). It works perfectly.

swaroop_anasane
Active Contributor
0 Kudos

Right Brian,

i18 functionality is what is leveraged in UI5 as well.

Regards,

Swaroop

swaroop_anasane
Active Contributor
0 Kudos

Hi Sam,

Apologies for confusion, what i was talking was no where related to MII standard implementations.

It was about using resourceModel in UI5 where in you can identify user's locale and tell UI5 to create resouce model as per user's locale or locale selected from dropdown.

Anyways parallel method is already implemented by Brian.


Thanks,
Swaroop

Answers (3)

Answers (3)

0 Kudos

Hello everyone,

The localization for MII web pages developed as content support international languages (all of them supported by Java) and the MII Admin pages (Web Dynpro based Menu items) support a subset of languages and this list is outlined in the SAP Product Availability Matrix (http://support.sap.com/pam). 

In the MII Workbench in the Meta-Inf tab for each project you will see the following path:

<Project Name> -> META-INF -> Bundles

If you right click on the "Bundles" folder you will be able to "Create a New Resource" where you can pick the language you would like to create a properties bundle for.  In this case for Spanish you can define the Key and Value pairs for localization.  In order for localization to work on your pages you have to end all of your web pages with the .irpt extension instead of using .html as the extension.  This tells the MII parser to traverse the HTML page prior to sending it to the client and it will replace all of the various keys on the page accordingly.  This is outlined in the MII help documentation here:

Project Localization - SAP Manufacturing Integration and Intelligence - SAP Library

In the login definition for your user you will also see a set of properties that MII uses to manage the session, including a "Language" property that comes from the NetWeaver UME language setting for your user.  To view all properties for a Role/User use this URL:

http://<ServerName:PortNumber>/XMII/PropertyAccessServlet?Mode=List

This language property field can be set using the MII JavaScript functions to whatever value you like and this will therefore override the localization of the page will be done based on the defined language of the session.  All of the UI5 and applet objects have this JavaScript function and this is what is used to manipulate and create session properties:

i5Grid.setPropertyValue(propertyName, propertyValue)

Sam

Former Member
0 Kudos

Ok, so I already had everything done according to your note above:

  • All of my pages have an extension of .irpt
  • I had two bundles set up (one for English (en), one for Spanish(es))
  • The user's "default" language was set to "en" (English) and I was seeing all of the pages in the correct language

However, I'm still stuck on being able to change the language dynamically.

If I append &Language=es to the URL, it does change the session value so that the "Language=es", but it does *not* pick up any values from my bundle. The English labels, button texts, etc are still visible - nothing related to my Spanish resource bundle shows on the screen - even after refreshing the screen.

Also, I'm not sure I understand what you're saying about setting a field using the MII JavaScript functions. The project I'm working on doesn't seem to have the SAPUI5 SDK installed or added. Are there non-UI5 functions I can call to set the language?


This language property field can be set using the MII JavaScript functions to whatever value you like and this will therefore override the localization of the page will be done based on the defined language of the session.  All of the UI5 and applet objects have this JavaScript function and this is what is used to manipulate and create session properties:

i5Grid.setPropertyValue(propertyName, propertyValue)

Former Member
0 Kudos

BUMP again...has no one done Internationalization/Localization in MII?

0 Kudos

Hey Sam,

Can you take a look at this one?  Interesting design approach.

Thanks, Mike (Moderator)

SAP Technology RIG

Former Member
0 Kudos

BUMP...anyone?