2016-10-04 56 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