In my UI5 application, I have an i18n.properties file with keys and values:
#XMSG:
qty=Quantity
And I'm using this property value in a dialog box as title
onUpdateDialog: function() {
var that = this;
var dialog = new Dialog({
title: "{i18n>qty}",
// ...,
});
dialog.open();
},
But when I run my application, the dialog box title is not getting displayed:
When I use text values from i18n property file somewhere else it's getting displayed.
ManagedObjects, that are created by the application code imperatively outside of the framework-managed features (Such creating an instance of sap.m.Dialog
in a Controller code without using the API loadFragment
), have to be added to the model delegation chain manually in order to make use of the propagated models.
In order to do so, add the created instance to the parent's <dependents>
aggregation. E.g.:
this.getView().addDependent(myDialog); // myDialog is now aware of the "i18n" model
From API Reference:
Special aggregation
dependents
is connected to the lifecycle management and databinding, but not rendered automatically and can be used for popups or other dependent controls or elements. This allows the definition of popup controls in declarative views and enables propagation of model and context information to them.
If there is no rendered UI element that can propagate the expected model data, set the target models manually:
// E.g. a reuse Component that has no UI to render but provides a dialog:
myReuseDialog.setModel(myManifestModel/*, modelName*/);
exit: function() { // Make sure to destroy the fragment manually then:
this.getMyReuseDialog()?.destroy();
MySuperClass.prototype.exit.apply(this, arguments);
}