未找到i18n.properties OpenUI5

时间:2016-10-04 04:41:14

标签: javascript jquery sapui5 resourcebundle

在VS2013中开发OpenUi5项目时遇到国际化问题。 i18n.properties无法获取:

  

“获取http://localhost:28091/i18n/i18n.properties 404(未找到)sap-ui-core.js:126”

这是我的项目设置:

./ I18N / 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>

非常感谢您的帮助。

2 个答案:

答案 0 :(得分:2)

我使用Visual Studios开发网络服务器遇到了同样的问题。

您必须通过在项目根目录中的web.config中提供mime映射来配置它以部署.properties文件:

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

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

答案 1 :(得分:0)

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

路径将从项目名称开始,所以如果 myProject 是项目名称,那么代码将为:

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