本教程的第八个步骤:
有朋友在评论区反馈:切换成中文时,Chrome 开发者工具 network 标签页看到一个资源文件加载的 404 Not found 错误:
http://localhost:8080/webapp/i18n/i18n_zh_CN.properties
谢谢这位朋友的反馈。确实,即使不指定任何 language 参数,直接访问如下 url:
http://localhost:8080/webapp/index.html
也能看到 i18n_en_US 和 i18n_en 这些资源文件的加载尝试。因为我 08 文件夹里只有 i18n.properties 文件,因此这两个加载尝试都失败,遇到 404 错误。
避免这些资源文件加载失败的方法很简单,在 i18n
文件夹里手动创建对应名称的 .properties
文件即可。
但更有价值的做法是,搞清楚为什么在 i18n.properties
文件加载之前,SAP UI5 会自动去加载 i18n_en_US.properties
和 i18n_en.properties
这两个