I see that the ResourceBundle is deprecated and is replaced by module:sap/base/i18n/ResourceBundle. When I use the latter one, I am not able to access the getText method to retrieve text from my i18n.properties file. PFA for the logs.


TIA
Request clarification before answering.
The module "sap/base/i18n/ResourceBundle" is available since 1.58. According to your screenshot, your application is running on 1.28, which is outdated and already out of maintenance.
Since it's a demo application, you can bootstrap the application with the latest stable version like this:
<script id="sap-ui-bootstrap" src="https://ui5.sap.com/resources/sap-ui-core.js"
data-sap-ui-libs="..."
data-sap-ui-async="true"
data-sap-ui-theme="sap_belize"
data-sap-ui-compatversion="edge"
data-sap-ui-xx-waitfortheme="true"
></script>The current stable version is at 1.58.x. With that, the module "sap/base/i18n/ResourceBundle" is available which you should define as one of the dependencies in the Controller:
sap.ui.define([
// ...,
"sap/base/i18n/ResourceBundle"
], function(/*...,*/ ResourceBundle) {
"use strict";
//...{
ResourceBundle.create({
url: sap.ui.require.toUrl("sap.ui.demo/i18n/i18n.properties"),
async: true //<-- Please use always async. Default is false.
}).then(function(bundle) {
var message = bundle.getText("wishMeMsg", [sRecipient]);
// ...
}.bind(this));
//}
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Meghana,
I'm not sure about the deprecation that you talked...
Anyway, try better this:
onInit: function() {
this.oBundle = this.getOwnerComponent().getModel('i18n').getResourceBundle();
}
wishMeNow: function() {
this.oBundle.getText("myText")
}
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "yourNameSpace.i18n.i18n"
}
},
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.