SAPUI5: How to Use the i18n Model in a Fragment or Dialog?

This is about how to use i18n in a fragment or dialog in SAPUI5.

It’s pretty straightforward.

So if you want to translate fragments or dialogs, this is for you.

Let’s get started!

How to Use i18n in a Dialog in SAPUI5?

You can use the i18n model in a fragment or dialog too—you just add the fragment or dialog to the dependent aggregation of the respective XML view.

For example:

<!-- in your XML view -->
...

  <Button text="Dialog" press="onPress"/>
 
...
// in your controller
...
   
onPress: function() {
      
  if (!this.oDialog) {         
     
    this.oDialog = new Dialog();     
 
  }
 
     
  // add the dialog to the view's dependent aggregation
  this.getView().addDependent(this.oDialog);     
  this.oDialog.open(); 
 
}

...

After you added the fragment or dialog to the dependent aggregation of the view, the internalization i18n model is available for them as well.

Leave a Comment