题
I have problem with Internationalization in SAPUI5.
I have a folder i18n and it has a file i18n.properties and inside it has NAME=app name SERVER= server name
I have a shell and inside onInit I have this code :
var oModel = new sap.ui.model.resource.ResourceModel({bundleUrl:"./i18n/i18n.properties"});
sap.ui.getCore().setModel(oModel, "i18n");
then I go to my View and and use it in my shell like this:
oShell = new sap.ui.ux3.Shell({
id:"main-shell",
appTitle:"{i18n>NAME}",
showPane:false,
showLogoutButton:false,
showTools:false,
});
this works fine.But when I go to another view and use it to get the server address it doesn't work for example i go to another controller and use it like this:
var URL="{i18n>SERVER}";
this code doesn't get resolved and stay the same as it is.
解决方案
You are trying to bind the value to a varaible, what you need to do is read from the bundle directly, one way to get the value is
var URL = sap.ui.getCore().getModel("i18n").getResourceBundle().getText("SERVER");
不隶属于 StackOverflow