0

Following this example, in SAP UI5 (I'm using 1.108 atm), the call to this.getOwnerComponent().getModel("i18n").getResourceBundle() returns a fulfilled promise instead of the resource bundle object.

Since what version or via what setting is this behaviour changed?

To cope with this, I'm using await in my formatter function:

sap.ui.define([], function () {
  'use strict'

  return {
    formatText: async function () {
      var oRB = await this.getOwnerComponent()
          .getModel('i18n')
          .getResourceBundle()
      return oRB.getText('hi')
    }
  }
})

Pieter
  • 1,751
  • 3
  • 30
  • 65

1 Answers1

1

Whether sap.ui.model.resource.ResourceModel#getResourceBundle returns a promise or the actual resource bundle depends on whether the respective ResourceModel is supposed to load the *.properties files asynchronously or not.

If e.g. the constructor setting of the ResourceModel has async: true, the API getResourceBundle returns a promise. Take a look at your ResourceModel settings in the manifest.json section /sap.ui5/models/i18n/settings. There, you must have "async": true.


Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170