2016-10-04 60 views
0

在VS2013中开发OpenUi5项目时,我遇到了国际化问题。该i18n.properties不能得到:i18n.properties未找到OpenUI5

“GET http://localhost:28091/i18n/i18n.properties 404(未找到)SAP-UI-core.js:126”

这里是我的项目设置:

./国际化/ i18n.properties

showHello=Hello 

./internationization/Main.controller.js

onInit: function() { 
    var oResourceModel = new sap.ui.model.resource.ResourceModel({ 
     bundleName : "i18n.i18n" 
    }); 

    sap.ui.getCore().setModel(oResourceModel, "i18n"); 
}, 

./internationization/Main.view.xml

<core:View 
     xmlns:core="sap.ui.core" 
     xmlns:mvc="sap.ui.core.mvc" 
     xmlns="sap.m" 
     controllerName="internationization.Main" 
     xmlns:html="http://www.w3.org/1999/xhtml"> 

     <Page title="Title"> 
      <content> 
       <Button text="{i18n>showHello}"/> 
      </content> 
     </Page> 
</core:View> 

非常感谢你为您的帮助提前。

回答

0

我使用视觉工作室开发的Web服务器有同样的问题。

你必须把它配置在你的项目的根提供在web.config MIME映射部署.properties文件:

<configuration> 
    <system.webServer> 
    <staticContent> 
     <mimeMap fileExtension=".properties" mimeType="application/text"/> 
    </staticContent> 
    </system.webServer> 
</configuration> 

只需添加<mimeMap/>元素及其家长,如果缺少。

+0

它工作!!!!!!非常感谢你的帮助,你为我节省了很多时间! @schnoedel – angwong

0

您需要在实例化ResorceModel时指定绝对路径。

也就是说路径将从项目名称开始,因此,如果myProject的是项目的名称,然后代码将是:

var oResourceModel = new sap.ui.model.resource.ResourceModel({ 
    bundleName : "myProject.i18n.i18n" 
}); 
+0

@Dopwdev谢谢您的回复。但它似乎没有按预期工作。 – angwong