0
votes

I am trzing to use i18n model for my view title but it is not showing correct title. Only variable it is showing.

**

here are my xml view details :

**

<mvc:View
controllerName="sap.ui.demo.myFiori.view.Master"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc" >
<Page
    title="{i18n>MasterTitle}" >
    <List
        items="{/SalesOrderCollection}" >
        <StandardListItem
            type="Active"
            press="handleListItemPress"
            title="{SoId}" />
    </List>
</Page>

**

  1. below is details from file messageBundle.Properties

**

MasterTitle=Sales Orders DetailTitle=Sales Order

**

details of Component.js file are as below :

**

jQuery.sap.declare("sap.ui.demo.myFiori.Component");

sap.ui.core.UIComponent.extend("sap.ui.demo.myFiori.Component", {

createContent : function() {

    // create root view
    var oView = sap.ui.view({
        id : "app",
        viewName : "sap.ui.demo.myFiori.view.App",
        type : "JS",
        viewData : { component : this }
    });

    // set i18n model
    var i18nModel = new sap.ui.model.resource.ResourceModel({
        bundleUrl : "i18n/messageBundle.properties"
    });
    oView.setModel(i18nModel, "i18n");

// // Using OData model to connect against a real service // var url = "/proxy/http/:/sap/opu/odata/sap/ZGWSAMPLE_SRV/"; // var oModel = new sap.ui.model.odata.ODataModel(url, true, "", ""); // oView.setModel(oModel);

    // Using a local model for offline development
    var oModel = new sap.ui.model.json.JSONModel("model/mock.json");
    oView.setModel(oModel);

    // done
    return oView;
}

});

Output is as below ![enter image description here][1]

In output it is showing MasterTitle instead of Sales Oreders

I want to display Sales Orders instead of MasterTitle in the title of Xml view page

1
I tried the same but it is showing MasterTitle onlz instead of Sales OrdersGAURAV WANI

1 Answers

0
votes

We should always use absolute paths relative to our own component. Because relative paths will fail if running in the Fiori Launchpad.

    var oRootPath = jQuery.sap.getModulePath("sap.ui.demo.myFiori");
    // Set i18n model
    var i18nModel = new sap.ui.model.resource.ResourceModel({
        bundleUrl : [oRootPath, "i18n/messageBundle.properties"].join("/")
    });
    this.setModel(i18nModel, "i18n");

You can put a break model at the last line and check if model holds any data or not.