I18n runtime mapping in MVC

This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.

Hi

We have a requirement to map i18n values from service to the MVC form widgets and alert messages. We tried calling the service in postappinit but getting 'Not authorised' error. This does not need an identity service to be mapped, still getting this error. Is this because of MF console not initialized?

When we try to call service from the onClick event of a button, it gets called and we get the response. This is what we have in code after response received in the onclick event

if(result !== null && result !== undefined){

var inputtable = {

"LBL_USERNAME": result["data"].key1,

"LBL_PWD": result["data"].key2

};

kony.i18n.setResourceBundle(inputtable,"en_US");

kony.print("i18 "+kony.i18n.getLocalizedString("LBL_PWD")); // prints the string

kony.i18n.setCurrentLocaleAsync("en_US",

function successCBi18n(){

kony.print("successCBi18n"); // printing this

}, function failureCBi18n(){

kony.print("failureCBi18n"); });

}

But the widget text is not refreshed immediately. If we close the app and open again it is refreshed with the new language values. But why is it not refreshing immediately?

We have seen in kony 6.5, if we navigate to another form, set locales there and destroy all other forms in background and navigate to the landing page, this used to refresh the data.

So we also tried the following but did not work

  1. navigating to another form ->destroy this current form -> set locale in navigated form by calling service for i18n -> navigate to prev form.
  2. navigating to another form -> set locale here by calling service for i18n ->destroy prevForm-> navigate to prev form.

we used

var ntf = new kony.application.previousForm();

ntf.destroy(); and then used kony.mvc.navigate() but we got 605 error in destroy();

Being in MVC, we could not get control on the other forms from a particular controller/action. How do we achieve the requirement? pl suggest

Thank you

Hi @Dvmivn Knott​ ,

Not authorised error can come when you try to make a service call without initialising mf sdk. At what point you are initialising SDK in your application?

Are you doing it in one of your modules or are you making use of auto-init functionality of Visualizer by building an app against runtime where your services are published?

We have associated in Visualizer the app against MF

Hi @Dvmivn Knott​ ,

if you have done that then your postappinit should work fine as We make sure that SDK is initialized before preappinit.

Can you attach your generated startup.js for us to check? Probably when you built your app, the fabric app was not published.

PFA the same

Hi @Dvmivn Knott​ ,

Startup.js looks fine. as per this the service call should work fine in postappinit.

Can you just attach snippet of the postappinit where service call is happening and also device logs where the error is coming.

Code snippet in postAppInit

InternationalizationService.internatoinalizationServiceCall();

The JS in modules it is as below:

var InternationalizationService = {

internatoinalizationServiceCall : function() {

kony.print("service call i18n");

KMFServiceUtil.invokeKMFServiceAsync("WOWService0",

"getInternationalizationData",

{"en_US"},

"internationlizationSuccessCB",

"internationlizationFailureCB",

"commonPopupForAlerts",

this);

},

internationlizationSuccessCB : function(result) {

if(result !== null && result !== undefined){

kony.print(result["data"]);

var inputtable = {

"LBL_USERNAME": result["data"].key1,

"LBL_PWD": result["data"].key2

};

kony.i18n.setResourceBundle(inputtable, "en_US");

kony.print("i18 "+kony.i18n.getLocalizedString("LBL_PWD"));

kony.i18n.setCurrentLocaleAsync("en_US",

function successCBi18n(){

kony.print("successCBi18n");

}, function failureCBi18n(){

kony.print("failureCBi18n");

});

kony.print("Locale is " +kony.i18n.getCurrentLocale());

}

}else{

kony.print("resp null "+result);

}

},

internationlizationFailureCB : function(error) {

AppUtil.dismissLoading();

kony.print("internationlizationFailureCB response ::: "+JSON.stringify(error));

}

};

PFA the log from ddms.

First 2 calls to service returned error (post app init and landing page post show)

But the third attempt - after navigating to another form and coming back to the landing page-was successful

Yet the widget data does not flush until i close and open the app again

Hi @Dvmivn Knott​ ,

So you are getting response from the service properly and getting data, just that it is not refreshing immediately?

Is that correct assumption? if yes, the issue is not with Fabric and you should not be getting unauthorised error for the mentioned service call in this snippet.

If data is not getting refreshed, it might be OS specific issue? for which platforms this is happening?

So you are getting response from the service properly and getting data, just that it is not refreshing immediately?

  • No not in appinit or post show. Only when there is a button click or a navigation and back then only im able to get response. All other times it says 17005
  • I need to set i18n at appinit itself which is not possible because of the error (issue #1)

Even if I try to do it on a button click data is not refreshed. This is the 2nd issue. I am not able to see in android mobile

@Adwivn Edmunds​ @Pvul Lvwwence​ @Isvvc Cvmewon​ any help here?

In auto init scenario, user is getting 17005 opstatus for service calls made in postappinit.

Good morning

Did you get any updates on this yet?

Hi,

As discussed, You need to make the i18n java service operation as public and then republish your app.

As your i18n service call is prelogin call so you made it as public and its working.

Thanks