cancel
Showing results for 
Search instead for 
Did you mean: 

Getting i18n text in controller

10-28-2015 11:02 AM
venkatachala_ck Active Participant
24994 views 3 comments Go to solution
SAP Managed Tags
Subscribe

Hi,

In dialog box i have sap.m.Text control

for that i have to set text which is there in i18n

i tried using below code its not working.

var dialogmasterlist = new sap.m.Dialog({

  title: 'Warning',

  type: 'Message',

  state: 'Warning',

  content: new sap.m.Text({

  text:"{i18n>notificationChangeAlert}"

  }),

  beginButton: new sap.m.Button({

  text: 'Yes',

press: function() {

       alert("Yes ");

       dialogmasterlist.close();

  }

}),

endButton: new sap.m.Button({

  text: 'No',

  press: function() {

       alert("NO");

       dialogmasterlist.close();

  }

  }),

});

In view its working problem only in controller.

View Entire Topic
sebastianraemsch
Product and Topic Expert
Product and Topic Expert

Hi,

You could also do it in the following way:


getResourceText: function(sKey) {

  jQuery.sap.require("jquery.sap.resources");

  var sLocale = sap.ui.getCore().getConfiguration().getLanguage();

  var oBundle = jQuery.sap.resources({

  url: "i18n/messageBundle.properties",

  locale: sLocale

  });

  return oBundle.getText(sKey);

}

Then it´s independent from you view model.

Best regards,

Sebastian